From 9c20069eb2bafb9e9fc9c6ab51660cee5054a8b0 Mon Sep 17 00:00:00 2001 From: freeCodeCamp's Camper Bot Date: Tue, 12 Mar 2024 22:29:52 +0530 Subject: [PATCH] chore(i18n,learn): processed translations (#53819) Co-authored-by: Oliver Eyton-Williams --- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- ...o-while-and-while-statements-in-c-sharp.md | 14 +- ...ng-the-switch-case-construct-in-c-sharp.md | 20 +- ...-and-logic-using-code-blocks-in-c-sharp.md | 20 +- ...xpressions-to-make-decisions-in-c-sharp.md | 2 +- ...ching-and-looping-structures-in-c-sharp.md | 20 +- ...lock-using-the-for-statement-in-c-sharp.md | 14 +- ...d-logic-to-c-sharp-console-applications.md | 6 +- ...-else-and-else-if-statements-in-c-sharp.md | 14 +- ...the-dot-net-class-library-using-c-sharp.md | 20 +- ...ctures-to-process-array-data-in-c-sharp.md | 20 +- ...ions-whitespace-and-comments-in-c-sharp.md | 20 +- ...ctures-to-process-array-data-in-c-sharp.md | 20 +- ...nstall-and-configure-visual-studio-code.md | 20 +- ...ys-and-the-foreach-statement-in-c-sharp.md | 14 +- ...eate-c-sharp-methods-that-return-values.md | 14 +- .../create-c-sharp-methods-with-parameters.md | 16 +- ...guided-project-plan-a-petting-zoo-visit.md | 20 +- ...methods-in-c-sharp-console-applications.md | 6 +- .../write-your-first-c-sharp-method.md | 14 +- ...le-application-using-visual-studio-code.md | 2 +- ...le-application-using-visual-studio-code.md | 10 +- ...andling-in-c-sharp-console-applications.md | 20 +- ...studio-code-debugging-tools-for-c-sharp.md | 20 +- ...f-code-debugging-and-exception-handling.md | 20 +- ...ophy-debug-c-sharp-console-applications.md | 6 +- ...ject-calculate-and-print-student-grades.md | 4 +- .../guided-project-calculate-final-gpa.md | 2 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- ...o-while-and-while-statements-in-c-sharp.md | 14 +- ...ng-the-switch-case-construct-in-c-sharp.md | 20 +- ...-and-logic-using-code-blocks-in-c-sharp.md | 20 +- ...xpressions-to-make-decisions-in-c-sharp.md | 2 +- ...ching-and-looping-structures-in-c-sharp.md | 20 +- ...lock-using-the-for-statement-in-c-sharp.md | 14 +- ...d-logic-to-c-sharp-console-applications.md | 6 +- ...-else-and-else-if-statements-in-c-sharp.md | 14 +- ...the-dot-net-class-library-using-c-sharp.md | 20 +- ...ctures-to-process-array-data-in-c-sharp.md | 20 +- ...ions-whitespace-and-comments-in-c-sharp.md | 20 +- ...ctures-to-process-array-data-in-c-sharp.md | 20 +- ...nstall-and-configure-visual-studio-code.md | 20 +- ...ys-and-the-foreach-statement-in-c-sharp.md | 14 +- ...eate-c-sharp-methods-that-return-values.md | 14 +- .../create-c-sharp-methods-with-parameters.md | 16 +- ...guided-project-plan-a-petting-zoo-visit.md | 20 +- ...methods-in-c-sharp-console-applications.md | 6 +- .../write-your-first-c-sharp-method.md | 14 +- ...le-application-using-visual-studio-code.md | 2 +- ...le-application-using-visual-studio-code.md | 10 +- ...andling-in-c-sharp-console-applications.md | 20 +- ...studio-code-debugging-tools-for-c-sharp.md | 20 +- ...f-code-debugging-and-exception-handling.md | 20 +- ...ophy-debug-c-sharp-console-applications.md | 6 +- ...ject-calculate-and-print-student-grades.md | 4 +- .../guided-project-calculate-final-gpa.md | 2 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../build-your-own-functions.md | 2 +- .../comparing-and-sorting-tuples.md | 2 +- .../conditional-execution.md | 2 +- .../data-visualization-mailing-lists.md | 2 +- .../data-visualization-page-rank.md | 2 +- .../dictionaries-and-loops.md | 2 +- .../dictionaries-common-applications.md | 2 +- .../files-as-a-sequence.md | 2 +- .../intermediate-expressions.md | 2 +- .../intermediate-strings.md | 2 +- .../introduction-elements-of-python.md | 2 +- .../introduction-hardware-achitecture.md | 2 +- .../introduction-python-as-a-language.md | 2 +- .../introduction-why-program.md | 6 +- .../iterations-definite-loops.md | 2 +- .../iterations-loop-idioms.md | 2 +- .../iterations-more-patterns.md | 2 +- .../loops-and-iterations.md | 2 +- .../make-a-relational-database.md | 2 +- .../more-conditional-structures.md | 2 +- .../networking-protocol.md | 2 +- .../networking-text-processing.md | 2 +- .../networking-using-urllib-in-python.md | 2 +- .../networking-web-scraping-with-python.md | 2 +- .../networking-with-python.md | 2 +- .../networking-write-a-web-browser.md | 2 +- .../python-for-everybody/object-lifecycle.md | 2 +- .../objects-a-sample-class.md | 2 +- .../objects-inheritance.md | 2 +- .../python-dictionaries.md | 2 +- .../python-for-everybody/python-functions.md | 2 +- .../python-for-everybody/python-lists.md | 2 +- .../python-for-everybody/python-objects.md | 2 +- .../python-for-everybody/reading-files.md | 2 +- ...xpressions-matching-and-extracting-data.md | 2 +- ...ular-expressions-practical-applications.md | 2 +- .../regular-expressions.md | 2 +- .../relational-database-design.md | 2 +- .../relational-databases-join-operation.md | 2 +- ...al-databases-many-to-many-relationships.md | 2 +- ...ational-databases-relationship-building.md | 2 +- ...-relationships-in-a-relational-database.md | 2 +- .../python-for-everybody/strings-and-lists.md | 2 +- .../python-for-everybody/strings-in-python.md | 2 +- .../the-tuples-collection.md | 2 +- .../using-web-services.md | 2 +- .../variables-expressions-and-statements.md | 2 +- .../visualizing-data-with-python.md | 2 +- ...services-api-rate-limiting-and-security.md | 2 +- .../python-for-everybody/web-services-apis.md | 2 +- .../python-for-everybody/web-services-json.md | 2 +- .../web-services-service-oriented-approach.md | 2 +- .../web-services-xml-schema.md | 2 +- .../python-for-everybody/web-services-xml.md | 2 +- .../working-with-lists.md | 2 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- ...dd-elements-within-your-bootstrap-wells.md | 12 +- ...ont-awesome-icons-to-all-of-our-buttons.md | 14 +- .../add-font-awesome-icons-to-our-buttons.md | 22 +- ...add-id-attributes-to-bootstrap-elements.md | 16 +- ...pply-the-default-bootstrap-button-style.md | 10 +- ...call-out-optional-actions-with-btn-info.md | 16 +- .../bootstrap/center-text-with-bootstrap.md | 10 +- ...create-a-block-element-bootstrap-button.md | 20 +- .../bootstrap/create-a-bootstrap-button.md | 12 +- .../bootstrap/create-a-bootstrap-headline.md | 20 +- .../bootstrap/create-a-bootstrap-row.md | 14 +- ...a-class-to-target-with-jquery-selectors.md | 8 +- .../bootstrap/create-a-custom-heading.md | 18 +- .../bootstrap/create-bootstrap-wells.md | 12 +- .../ditch-custom-css-for-bootstrap.md | 22 +- .../give-each-element-a-unique-id.md | 20 +- ...-within-a-bootstrap-container-fluid-div.md | 12 +- .../bootstrap/label-bootstrap-buttons.md | 18 +- .../bootstrap/label-bootstrap-wells.md | 16 +- ...rm-elements-responsively-with-bootstrap.md | 16 +- .../make-images-mobile-responsive.md | 18 +- .../responsively-style-checkboxes.md | 12 +- .../responsively-style-radio-buttons.md | 14 +- .../bootstrap/split-your-bootstrap-row.md | 10 +- .../style-text-inputs-as-form-controls.md | 16 +- ...aste-the-bootstrap-button-color-rainbow.md | 14 +- .../use-a-span-to-target-inline-elements.md | 24 +- .../bootstrap/use-comments-to-clarify-code.md | 18 +- ...-design-with-bootstrap-fluid-containers.md | 20 +- ...strap-grid-to-put-elements-side-by-side.md | 22 +- ...s-of-a-dangerous-action-with-btn-danger.md | 12 +- .../build-a-25-5-clock.md | 70 +- .../build-a-drum-machine.md | 30 +- .../build-a-javascript-calculator.md | 52 +- .../build-a-markdown-previewer.md | 28 +- .../build-a-random-quote-machine.md | 38 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 67 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../exercise-tracker.md | 2 +- .../file-metadata-microservice.md | 2 +- .../request-header-parser-microservice.md | 2 +- .../timestamp-microservice.md | 2 +- .../url-shortener-microservice.md | 2 +- .../meet-the-node-console.md | 12 +- .../start-a-working-express-server.md | 2 +- ...e-of-any-node.js-project-or-npm-package.md | 8 +- .../mongodb-and-mongoose/create-a-model.md | 2 +- .../install-and-set-up-mongoose.md | 2 +- .../test-if-a-value-is-an-array.md | 2 +- .../american-british-translator.md | 2 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../64dcd3d61c448e2676501f43.md | 2 +- .../64dcd9bbc2268127e7898d77.md | 2 +- .../64de773f81facd14653f49c8.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- .../install-and-require-helmet.md | 2 +- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../62bb4009e3458a128ff57d5d.md | 4 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 4 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../5d5a813321b9e3db6c106a46.md | 4 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8c5db7888af27af23f0dd.md | 2 +- .../62a8c6815f5f1a29735efe1b.md | 2 +- .../62a8c7322e42962ad53ad204.md | 2 +- .../62a8c8cee8e5cf2e001789b4.md | 2 +- .../62a8cb19bd7f8a304e5427a1.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8cce1b0c32c33017cf2e9.md | 2 +- .../62a8ce73d0dce43468f6689c.md | 2 +- .../62a8d0c4f12c2239b6618582.md | 2 +- .../62a8d143f2a58e3b6d6e9c33.md | 2 +- .../62a8d2146a3e853d0a6e28ca.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd468debb449b4454086.md | 2 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62a8e142f7f0bd4fed898de3.md | 2 +- .../62a8e1dc897df55108bcb5e8.md | 2 +- .../62a8e271f8e3d1541f9624ad.md | 4 +- .../62a8e41e2f190c58404dd46e.md | 2 +- .../62a8e45cc600c3591cee671a.md | 2 +- .../62a8e49f4df7af5ae2d7a616.md | 2 +- .../62a8ed36d7a7915dfa444ba2.md | 2 +- .../62a8edd05e27cc668051686f.md | 2 +- .../62a8eec45f77bc69e8775294.md | 2 +- .../62a8eefe2e68b66ac563816b.md | 2 +- .../62a8ef8f0c76a46cd221a68c.md | 2 +- .../62a8efb0e3ce826db8daf80f.md | 2 +- .../62a8f06fb318666fef69f91e.md | 4 +- .../62a8f14fe6d1fc72454648c7.md | 2 +- .../62a8f1d5f5ddbf74c07f733b.md | 2 +- .../62a8f256b813a476cae51f49.md | 2 +- .../62a8f35bde1750791f58773f.md | 2 +- .../62a94114ce0b8918b487390f.md | 2 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa204c1e1d33348ff09944.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 6 +- .../62aa2136fc49b836dfedb959.md | 2 +- .../62aa21ea8d9d9f396b95dd87.md | 2 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62aa234322d4ad3e8bce42cc.md | 2 +- .../62aa258da314ef42ba0a1858.md | 2 +- .../62aa25fcb5837d43b4d9873d.md | 2 +- .../62aa2626c3c10244b94c787b.md | 2 +- .../62aa264d23cdaa45a20efada.md | 2 +- .../62aa26cca3cd3d46c431e73b.md | 2 +- .../62aa27c40ca6f04ab8be5fac.md | 2 +- .../62aa28032d863d4bd8058799.md | 2 +- .../62aa28bbd6323e4dfb3ac43e.md | 2 +- .../62aa28fb651bf14efa2dbb16.md | 2 +- .../62ba17beef16c563069a65d8.md | 4 +- .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63b60d3c5048302906962231.md | 4 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../651dd5ae6ffb500e3f2ce47c.md | 4 +- .../657b05367b59300bcb5f18ef.md | 2 +- .../657b068e28a3bd135ced0042.md | 2 +- .../657b08655966781abf6396ff.md | 2 +- .../657b0b0c01616c2382ee7dc1.md | 10 +- .../657b0cbc53235932265cbd9d.md | 20 +- .../657b130a905a6045ebe03214.md | 2 +- .../657b16a8bda80c524e49edd1.md | 2 +- .../657b1803cae7df58348e4e01.md | 2 +- .../657b190c4e736f5c4005b132.md | 2 +- .../657b1ae0c2fb4c64071ade7a.md | 24 +- .../657b24875b782f8c6c85472f.md | 2 +- .../657b24e5edd7708e93549565.md | 2 +- .../657b292a911788a7faf67415.md | 2 +- .../657b2d1876594db821b5da16.md | 10 +- .../657b2e9f139789bdd50116b5.md | 2 +- .../657b30777fcf90c40b9d7ca8.md | 2 +- .../657b316b61644cc96b677e61.md | 2 +- .../657b69e10d6606a0185d4d4f.md | 2 +- .../657b6ea501ca10ae78922b0d.md | 2 +- .../657b6f641e5c3ab1afc6efc1.md | 2 +- .../657b70cc934e0ab83cab4dbe.md | 2 +- .../657b718282cd56bb91a795de.md | 2 +- .../657b7acdc06454fbb0152538.md | 2 +- .../657b7bad0b215cff2128139a.md | 2 +- .../657b7d1aec6d4803cf02e84f.md | 2 +- .../657b7d76e9447705f7e5ceb8.md | 2 +- .../657b7e633c982f095101e6fe.md | 2 +- .../657b8278a00d27196af26c6c.md | 2 +- .../657b92b25858f24caf6894aa.md | 2 +- .../657b971e15225e53da93afd3.md | 2 +- .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 8 +- .../657cb68bf15f349a744b5fba.md | 2 +- .../657cbb578ed7f5a52420d274.md | 2 +- .../657cbdc0c360a3b53767d73f.md | 2 +- .../657cbef9aa43ceba8af6feb4.md | 2 +- .../657cc1a2ced22ac3e7d57fd3.md | 2 +- .../657cc2b9cc9e97c7bd862273.md | 2 +- .../657cd0e53b947df11ce91026.md | 2 +- .../657cd143f74299f36a624c7a.md | 2 +- .../657cd1925ac059f5034286c3.md | 2 +- .../657cd2dce697d2feacf7620d.md | 2 +- .../657cd962b45f48127c183d7b.md | 2 +- .../657cdaeee8cc4517f84911a2.md | 2 +- .../657cdd8bd3ebae2165d46a99.md | 2 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../657ce1f82fbe552fcba96375.md | 2 +- .../657ce22e1bdf763280ae1e2b.md | 2 +- .../657ce9e5593ae449e7ae6073.md | 2 +- .../657cea90396c694e4fdcaeba.md | 2 +- .../657ceafb64fd6a5076b32c8b.md | 2 +- .../657cece074e011590731dee2.md | 2 +- .../657ced8b322c055e500c2d23.md | 2 +- .../657cfddfaca4b58b1279aaf9.md | 2 +- .../657cfe38b7aa33903ac91d6d.md | 2 +- .../657cfe92331ff7926a65dc47.md | 2 +- .../657cfeeeabb34d946d437dc7.md | 2 +- .../657cff86dd812f98672e2649.md | 2 +- .../657dbd1ebf21b2096966fe0d.md | 2 +- .../657dbdae2bd6f60bda3226cc.md | 2 +- .../657dbfb128eaef185f5fb51b.md | 2 +- .../657dc02d216cf41afa064333.md | 2 +- .../657dc06c17779b1c77b8fccf.md | 2 +- .../657dc0e16fb76f1f02a0c02a.md | 2 +- .../657dc130b35c3a20c8908eb1.md | 2 +- .../657dc1d18a0a6f25302badba.md | 2 +- .../657dc45d37cb4a32eae1fd7a.md | 2 +- .../657dc4c403f74135e0a8c7be.md | 2 +- .../657dc568fe84e53acc962fc3.md | 2 +- .../657dc5b1c14b693ce0584837.md | 2 +- .../657dc6a58ec0be432655eaf5.md | 2 +- .../657dc71c76da6e475ad4eb4f.md | 2 +- .../657dc9004d076d55baf36323.md | 2 +- .../657dca3c709bf15dd0572a6b.md | 2 +- .../657dca763bc23c5fc3398d95.md | 2 +- .../657dcdb62814646de1b051c0.md | 2 +- .../657dce8ff35869721311a5e3.md | 2 +- .../657dcee413423174ca3747f5.md | 2 +- .../657dcf9f7d5c747a19a36c9c.md | 2 +- .../657dd047e755e37d58f5084f.md | 2 +- .../657dd09e586b597fe5cd0d3d.md | 2 +- .../657dd46946896b8d19484e26.md | 2 +- .../657dd5ff705f8b94667b03a8.md | 2 +- .../657dd6d4bd7e3b98294dd4a5.md | 2 +- .../657dd74fb90e759a783f4b9a.md | 2 +- .../657ddd7d4fc512b03741d9a3.md | 2 +- .../657dde3c405eaab3e21b38bf.md | 2 +- .../651dd5296ffb500e3f2ce479.md | 2 +- .../651dd5386ffb500e3f2ce47a.md | 2 +- .../6537e6ece93e5724eeb27c54.md | 2 +- .../6543aa3df5f028dba112f275.md | 2 +- .../6543aaa9f5f028dba112f276.md | 2 +- .../6543abeff5f028dba112f278.md | 2 +- .../6543abf5f5f028dba112f279.md | 2 +- .../655283c039eb38f51e0e6f7e.md | 2 +- .../65528a7c39eb38f51e0e6f7f.md | 2 +- .../65529784e7cb6e24eb03a1af.md | 2 +- .../6568bf620d3e770ea770123f.md | 2 +- .../6568c0f3792d990efe47949e.md | 2 +- .../6568c181c8a1420f262b698b.md | 2 +- .../6568c3539307ad0f902d20e7.md | 2 +- .../6568c3d772f1460fc81f40e9.md | 2 +- .../6568c618310cf51076e23d33.md | 2 +- .../6568c759cb59e810dfaa1506.md | 2 +- .../656a0d0e74f6a40d87328d38.md | 2 +- .../656a0dde6087df0dd5729d6e.md | 2 +- .../656a0eaf7d37610e43662464.md | 2 +- .../656a0f4f303dce0e865e746b.md | 2 +- .../656a10141825a30eb81ff4db.md | 2 +- .../656a10aaa023200eddd09d88.md | 2 +- .../656a1298f2a0400f56b31e25.md | 2 +- .../656a13f01a59cb0fc9d52149.md | 2 +- .../656a14b0e1c43d0ffabd15a9.md | 2 +- .../656a18189b21f51037e518b4.md | 2 +- .../656a2b1c7216c026fcd156c7.md | 2 +- .../656a3f5be79ce02dcc157d6b.md | 2 +- .../656a3fd085a6e92dfbaee96a.md | 2 +- .../656a401d1b00af2e25b0fd8b.md | 2 +- .../656a417f7f9daf2e9aae6831.md | 2 +- .../656a4297fcc0d72ef9b60c21.md | 2 +- .../656a4e97fa176a2fed5011fc.md | 2 +- .../656a4f714165773059ce7ad4.md | 2 +- .../656a503aa1f2c630b3951067.md | 2 +- .../656a509eeac7e030e2a16bab.md | 2 +- .../656a510695ccb03109117af0.md | 2 +- .../656a51895811ed31345b2eaf.md | 2 +- .../656a51effc10b2316bad8479.md | 2 +- .../656a52da3392f631b9f3e022.md | 2 +- .../656a538cc4109d3209f5f536.md | 2 +- .../656a54278a4df6323549e8f9.md | 2 +- .../656a55ea17414032d482d278.md | 2 +- .../656a56f89acf253314e9f6d6.md | 2 +- .../656a575febfa2c333c495c2f.md | 2 +- .../656a57d2c0603e33638c7770.md | 2 +- .../656a584f57a1a9338e3cb347.md | 2 +- .../656a58b31bc9f233debc2bc9.md | 2 +- .../656ab3bfc9e49d4841672043.md | 2 +- .../656ab4205a4054486ef3b691.md | 2 +- .../656ab48697d63748952254a4.md | 2 +- .../656ab50005c38348b94da7a3.md | 2 +- .../656ab61f20aa9d494cee5466.md | 2 +- .../656ab66db70b464974489b79.md | 2 +- .../656ab6f67515b149a377009d.md | 2 +- .../656ab76473a1ee49d537698d.md | 2 +- .../656ab828bd06214a51193f3d.md | 2 +- .../656ab8a1d294e14a920320d2.md | 2 +- .../656aba8d560d3c4b069ae7a8.md | 2 +- .../656abac861f4a04b312b0421.md | 2 +- .../656abb977f9ecf4b821aed11.md | 2 +- .../656abcd4cccfc84bf50f861b.md | 2 +- .../656abe0ac290774c4de173d4.md | 2 +- .../656caddea3aba304c6172571.md | 2 +- .../656caf2085b7ab04ff9a6b3f.md | 2 +- .../656caf89ead43c0523378566.md | 2 +- .../656cb2526a741405b2b34870.md | 2 +- .../656cb3592aa0460609993b10.md | 2 +- .../656cb39802398f062c461e2c.md | 2 +- .../656cb3f8df42660676854d29.md | 2 +- .../656cc3b856f1d01011bfc027.md | 2 +- .../656cc4aa4726711043189619.md | 2 +- .../656cc523e668741073c4e916.md | 2 +- .../656cc5d403162710a3fae634.md | 2 +- .../656cc6259c711d10cde2c486.md | 2 +- .../656cc6981cbf2711196a284f.md | 2 +- .../656cc6dd00af9f117f10446b.md | 2 +- .../656cc73e6b1c6811a73b04bb.md | 2 +- .../656cc86fc6a990122ac6c6a1.md | 2 +- .../656cc8dafb6343124f729ec5.md | 2 +- .../656cc92ecdebaa1278505e87.md | 2 +- .../656cc98cfe781112ace7d3ee.md | 2 +- .../656cca055e5d1912d9784ce1.md | 2 +- .../656cca6bb44ce5130a759829.md | 2 +- .../656ccd12c27bf013529db8ce.md | 2 +- .../656cce9ebec3c01412c0e564.md | 2 +- .../656ccf01c07406143b90ff84.md | 2 +- .../656cd00707c0d614c38e7416.md | 4 +- .../656cd0c550a08915211f32ce.md | 2 +- .../656cd17584250515779ca7e5.md | 2 +- .../656cd1ca72b3e615a33c05b6.md | 2 +- .../656cd22d91db1915cb11f584.md | 2 +- .../656cd27f38f17f15f06f6ed6.md | 2 +- .../656cd52f0f43551be96b4640.md | 2 +- .../656cd63a45146d1c2c51e682.md | 2 +- .../656cd6a37495961c5f242c5d.md | 2 +- .../656cd83ad397f61ce1259ad6.md | 2 +- .../656cd8d68948d11d201308d4.md | 2 +- .../656cd9f4e30e6d1d81f0e62d.md | 2 +- .../656cdab71161371dd6b0a401.md | 2 +- .../656cdb10b568061e0bd6757f.md | 2 +- .../656cdcc291e5531ea11a8f2a.md | 2 +- .../656d199a0d5c10050b7e8241.md | 2 +- .../656d19d9ab6e0c052edfb1e7.md | 2 +- .../656d1ad4fbdb51057f0f0714.md | 2 +- .../656d1becadf67d05d5b27bab.md | 2 +- .../656d1d1f46bc820629aecc0d.md | 2 +- .../656d2600b0ffa811dac3853f.md | 2 +- .../656d266537ff53120d194ae8.md | 2 +- .../656d26bc907ce0123546288a.md | 2 +- .../656d283b7ba56912bb2ceb06.md | 2 +- .../656d2914e7cfc312ea00c864.md | 2 +- .../656d2a2ed95bfa1345fd9fd1.md | 2 +- .../656d2aee945ce2137bd8b8b8.md | 2 +- .../656d2b6aaad95013a86cea6c.md | 2 +- .../656d2d19c570e2146b5e8835.md | 2 +- .../656d2f31f23860155477ca7b.md | 2 +- .../657e0d0037192f3d9e3d5417.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 52 +- .../657b106ced8c653be6b3218f.md | 52 +- .../657b108cf870283d22b21e8e.md | 52 +- .../657b110ad8afcc3f8e586362.md | 52 +- .../657b115008a62d41c0d7482f.md | 49 +- .../657b119f0ce64343420bb850.md | 49 +- .../657b11e082e48a44eb4bfc09.md | 54 +- .../657b11f87368cf463ea4fe46.md | 52 +- .../657b1240ef768447b80817ad.md | 51 +- .../657b12ae08dd7049b300c901.md | 49 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 49 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 52 +- .../657b1431076b365555784189.md | 49 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 49 +- .../657b14d8353d665a187fe771.md | 71 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 52 +- .../657b160d6a8662610fe6a523.md | 60 +- .../657b163c9da40e62b904be1f.md | 54 +- .../657b18e71067d6680b9ac5d3.md | 54 +- .../657b1985ae17886b05b382b1.md | 54 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 52 +- .../657b1a27dc6daf6ffd52ff1f.md | 78 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 60 +- .../657b1cc072206e7ac3db88b8.md | 53 +- .../657b1d080265ba7c4f96bf79.md | 52 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 64 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 61 +- .../657b1e66159fec86336a737b.md | 52 +- .../657b1e9a62603587747f7f45.md | 3 +- .../657b1ee1de7216896b5b4361.md | 83 +- .../657b1f0585d48f8ac0b19654.md | 79 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 60 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 4 +- .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 4 +- .../657b221b2ab0ac9e18a173ef.md | 3 +- .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 77 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 47 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 3 +- .../657b24542024c8af092cd6c4.md | 51 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 52 +- .../657b2d618b8851cc5baf9490.md | 48 +- .../657b2d9cb974dace59024964.md | 52 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 52 +- .../657b2f3bf7a2cbdb58d959d5.md | 49 +- .../657b2f6cb66826dcbac08094.md | 49 +- .../657b2fa89ddc20de629ca21f.md | 54 +- .../657b2fc9c0f96bdfddfce4d9.md | 52 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 52 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 52 +- .../657b315533e4edeba65111b8.md | 52 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../655b5cc5a8b3897908c962f0.md | 2 +- .../655b5d955d8b2679be66a4db.md | 2 +- .../655b5ef161f6777ae5eb3ba4.md | 2 +- .../655b62a491cb2d7c687a1a2a.md | 2 +- .../655b63d0da84237d16c55d7e.md | 2 +- .../655b672f02003c7ecec12ffe.md | 2 +- .../655b67f02eecf57fa75ceecf.md | 2 +- .../655b6a58626e2a82be5a78eb.md | 2 +- .../655b6ca9c3e001838ac22d17.md | 2 +- .../655b76340ecb8285060ab6d5.md | 2 +- .../655bd2158780e2421b674e61.md | 2 +- .../655bd798ce91bd4861b69281.md | 2 +- .../655bd91a858b2b4a30da3cad.md | 2 +- .../655bda6270ef334ad8a7f005.md | 2 +- .../655bdc7e9c4116509df13f34.md | 2 +- .../655bdf9f7f844952b7e7f036.md | 2 +- .../655be33b7a463a5593c91cb4.md | 2 +- .../655c9a89818e18606c18ca4b.md | 2 +- .../655c9b2e0bcbe16161996ab7.md | 2 +- .../655c9bcb5bedb4620acb6f18.md | 2 +- .../655ca014b022ff6692049b91.md | 2 +- .../655cadb5df07e269cccaa056.md | 2 +- .../656918c77e73780c34392e17.md | 2 +- .../656a43974f689442c0a0eeb2.md | 2 +- .../656a44b06bea9443b8ff45bd.md | 2 +- .../656a456b46b4b04437f2d3e9.md | 2 +- .../656a46814617c04516f698eb.md | 2 +- .../656a4758b0f85e45d03f9e17.md | 2 +- .../656a4815c0d43346a2e27b51.md | 2 +- .../656a48d41b97ff476586ee9c.md | 2 +- .../656a4ac4529e0f49ab900c3b.md | 2 +- .../656a4afc5f944649f391898f.md | 2 +- .../656a4b9e4822ba4a9893459e.md | 2 +- .../656a4bea53d6fd4ae86bdb70.md | 2 +- .../656a4c42ee183c4b3b92bfeb.md | 2 +- .../656a4d1943d8f24c030ded74.md | 2 +- .../656a4d74286f4d4c4ae58de0.md | 2 +- .../656a4dd03541de4ca98a61e8.md | 2 +- .../656a4e35a774444d1946a899.md | 2 +- .../65569ebbc9ef9f7b5b99827b.md | 2 +- .../6556ba2fe6c3f3846ea71ab2.md | 2 +- .../6556bc95e6ce5d850d37dd07.md | 2 +- .../6556be93f9fcb88ac9e88b0d.md | 2 +- .../6556bfd76c3fc38ba94ccf5e.md | 2 +- .../6556c456a11da38ed3275f67.md | 2 +- .../6556c5977ba8d5900c230ce5.md | 2 +- .../6556c78eac427390aafa26ff.md | 2 +- .../65578ed1a4ae65a8fbc341f5.md | 2 +- .../6557985a95ab6db1c4a31b6c.md | 2 +- .../6557995f0d97e1b2837a3081.md | 2 +- .../65579a0e1613d5b31a034ee5.md | 2 +- .../6557aee56ed7dcb5506a66d6.md | 2 +- .../6557b2f6f90e6eb703cd2307.md | 2 +- .../6557b68486fe9bb7b52a4308.md | 2 +- .../6557bb81a99580b97a8b1c3b.md | 2 +- .../6557bd443a1a57ba598bff47.md | 2 +- .../6557c1dff9d170bc911fd82b.md | 2 +- .../6557c30b85e792bd0c1e8206.md | 2 +- .../6557d6a229e541bfde2c560d.md | 2 +- .../6557d782bc7613c06aa7dafd.md | 2 +- .../6557dc1aa6be93c1eb4e9efb.md | 2 +- .../6557dea8c258c1c2a767deb7.md | 2 +- .../6557e0adbee371c3ac455a01.md | 2 +- .../6557e2aca332a4c4c0359ed5.md | 2 +- .../6557e5c6a854bfcad48808c4.md | 2 +- .../655a235215bab7fa2a2e4bb7.md | 2 +- .../655a24f27d595bfb53f1bb3e.md | 2 +- .../655a2a597d94f7fcc2f6126e.md | 2 +- .../655a3132c16520fe6bf8f9be.md | 2 +- .../655a35731cb3fc0152ebcf60.md | 2 +- .../655a367638e3f401eb0235ea.md | 2 +- .../655a3789069fc902eb2aaa4b.md | 2 +- .../655a3b8981a93f05bbfea7ba.md | 2 +- .../655a497a3afaf10b336746a5.md | 2 +- .../655a4a5af997350c187bd779.md | 2 +- .../655a4fc35818d90f73f63ba0.md | 2 +- .../655a505171c360103cf718f9.md | 2 +- .../655a51cff12fb7117aa611f9.md | 2 +- .../655a52d92a586612be333b16.md | 2 +- .../655a54506b259313b2d59577.md | 2 +- .../655a5630b68570156ea7d80e.md | 2 +- .../655a57579afa8d173304b239.md | 2 +- .../655a5bfadf47e1199f9b65eb.md | 2 +- .../655a78fdfac0e22b0c400e72.md | 2 +- .../655a88194beb4332037ff7ce.md | 2 +- .../655a896f31ca6a32913d1106.md | 2 +- .../655a8ae1f10749350bc8820f.md | 2 +- .../655a8b62e5681235c3fb5492.md | 2 +- .../655a8d7c939fcf37604516e4.md | 2 +- .../655a8ecc0cad80393b5f3b5b.md | 2 +- .../655a8fcbb859993a93204e44.md | 2 +- .../655aa098bb38a05474a3f5b4.md | 2 +- .../655b258e8cd2985ed8412275.md | 2 +- .../655b266c2ea5495f43b97ea5.md | 2 +- .../655b275cadbebf5fc0f0db05.md | 2 +- .../655b2919ff561b60fcde19ae.md | 2 +- .../655b2b5cc4ea3062f9811dec.md | 2 +- .../655b2d250741166530dd6e43.md | 2 +- .../655b3197bb31ca670081f6d7.md | 2 +- .../655b3274b6c61c67d95b5e67.md | 2 +- .../655b363149b5ba6b15434574.md | 2 +- .../655b38c1f5351d6c827c8e8f.md | 2 +- .../655b3b06ec00a46e572868a2.md | 2 +- .../657a45a85a8f6cfeef7803db.md | 2 +- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e005227c77535223f3062.md | 2 +- .../657e00b8edd9c338225cbce5.md | 4 +- .../657e05f30925c93d93c03fe3.md | 2 +- .../657e067b7581045341f106d8.md | 2 +- .../657e06eca8147f561619be7d.md | 4 +- .../657e07580285f658d1f98cfe.md | 2 +- .../657e0868da73165e32763679.md | 2 +- .../657e0973aa91c662814c2ecf.md | 2 +- .../657e0a7303e5cb66e907e26d.md | 2 +- .../657e0b605954eb6b04279b12.md | 2 +- .../657e0f15eb5e5b77ce1a39c2.md | 2 +- .../657e11ce088244825548e702.md | 2 +- .../657e1917c1cada9b20c2e7a2.md | 2 +- .../657e1baa6a02c1a5b9a1157f.md | 2 +- .../657e1c10bc3f2ea8e1c1d7f7.md | 2 +- .../657e1d9d0f894eafabc6d23c.md | 2 +- .../657e1e51ad0db7b615666f27.md | 2 +- .../657e251157e07ecca1047516.md | 2 +- .../657e2598996daacf116c5223.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e28253d33dedb2cbb5517.md | 2 +- .../657e28a8520595ddd5cf9757.md | 2 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2a31c7f3e5e4a599a589.md | 2 +- .../657e2abf597d97e7ba03e7e2.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 4 +- .../657e2c85b80142efb0dcb6fa.md | 2 +- .../657e2d40be7141f2c8cc9cc0.md | 2 +- .../657e2e9eacd141f7af2cea66.md | 2 +- .../657e2fd87f8812fb05c551f5.md | 2 +- .../657e307876468dff6e505438.md | 2 +- .../657e31b82090130535456f65.md | 2 +- .../657e3228f9f24007a7d59779.md | 4 +- .../657e395562fe3e25b7c1f5c0.md | 2 +- .../657e39bace982b283ed8cd3f.md | 2 +- .../657e3b269f12863096144d58.md | 2 +- .../657e3ccfae39363a313b2f6b.md | 2 +- .../657e3dfda31b534042d06e39.md | 2 +- .../657e3fd446b9544b77a2bc21.md | 2 +- .../657e44316a7b8161437a7853.md | 2 +- .../657e45c723bc3d6aed2b5997.md | 2 +- .../657e47111ec36d6fe97e09d2.md | 2 +- .../657e4964fa7c9b7e6aa7428c.md | 2 +- .../657e4a824ba68884c14f68b9.md | 2 +- .../657e4aec56a5518728ebf1c0.md | 2 +- .../657e4b38e008b289acc8155c.md | 2 +- .../657e4dfc07e48897111f235f.md | 2 +- .../657e4e482e3a38992b212c6f.md | 2 +- .../657e4ec6dd27af9cc16addea.md | 2 +- .../657e4f2649f8669f7d78e0a5.md | 2 +- .../657e4fc397780aa2bc046ed7.md | 2 +- .../657e50576597e0a65cd97e24.md | 2 +- .../657e50dd1f6ff2a9873f9ff0.md | 2 +- .../657e51344c206eabd5ffb872.md | 2 +- .../657e5171f6746eadc5c6411f.md | 2 +- .../657e5280003334b1726df8a2.md | 2 +- .../657e53d4cbe247b9d039f2c2.md | 2 +- .../657e551a5b6002c060324a6a.md | 2 +- .../657e557fbed711c290078295.md | 2 +- .../657e5719e17f40ca906b8c63.md | 2 +- .../657e5879357fe6d2bbbdc2f0.md | 2 +- .../657e58fdd69045d587e1e191.md | 2 +- .../657e597aecc28ed883309243.md | 2 +- .../657e59cbf4dd1fdb27f65e98.md | 2 +- .../657e5a9dbb276fdf539b8279.md | 2 +- .../657e5bb8ac166ee76a69be96.md | 2 +- .../657e5cdc1cd7fdef185e11e5.md | 2 +- .../657e5f36243f4cfc7304fc25.md | 2 +- .../657e5fa49b69deff5e9bff8e.md | 2 +- .../657e60811cb0f305e56bbe31.md | 2 +- .../657e6117bebfda097995f2b7.md | 2 +- .../657e6f00a5b48342ab1ec702.md | 2 +- .../657e6f53e4d8ff44a944154b.md | 2 +- .../657e6f8bfecef34627817aa6.md | 2 +- .../657e6fcfdbf4c14806fbfe26.md | 2 +- .../657e704f452a044b427e96d2.md | 2 +- .../657e70aa0abc044d54937aa9.md | 2 +- .../657e7116e4db87501f898f79.md | 2 +- .../657e7194d581bf52d96d452d.md | 2 +- .../657e71f3ad85395555f50f8c.md | 2 +- .../657e723a564da6572b98ceef.md | 2 +- .../657e727a9c574f58cb16b5f8.md | 2 +- .../657e7318f9fe365ba838011d.md | 2 +- .../657e73d16e30645fcfc489b7.md | 2 +- .../657e741a7309f661e0a48909.md | 2 +- .../657e759a72dd0c67f8992ff5.md | 2 +- .../657e761058c1e469fb387f68.md | 2 +- .../657e77b682b49f70a3adcc0a.md | 4 +- .../657d50434d1a007661712182.md | 2 +- .../657d572d0a7e49837a3e63dc.md | 2 +- .../657d5a9cbf7f0e84f2ca16d7.md | 2 +- .../657d5b2d1fe085857b5083f2.md | 2 +- .../657b2296130e541911943345.md | 2 +- .../657b236691c67b197cd382f4.md | 2 +- .../657b400653813a1caa228aca.md | 2 +- .../657b438144bd421e49e202e2.md | 2 +- .../657b44fd1219f01f3afa8fb1.md | 2 +- .../657b5bd17d068521ee895631.md | 2 +- .../657b5c45e603ca227abf904a.md | 2 +- .../657b5de322bdee236e353230.md | 2 +- .../657b5f2319bc2223f2fc408a.md | 2 +- .../657b615cdee8f12537d6f90c.md | 2 +- .../657b661cc0427227c7e7aec0.md | 2 +- .../657b66c57499db2828adac5e.md | 2 +- .../657b674c711e5428985017ca.md | 2 +- .../657b67daf0b2d128ece96345.md | 2 +- .../657b68caf6debb2975503948.md | 2 +- .../657b6a7dd8fb2f2a52da24f5.md | 2 +- .../657c9900c2df3b6ffdd86129.md | 2 +- .../657c99c084204371fcb8d6a8.md | 4 +- .../657ca06716e21b803ffb55d5.md | 2 +- .../657ca36eacc797817451ece6.md | 2 +- .../657ca45e1fc9398243722c8c.md | 2 +- .../657ca59e6e559782e4c10056.md | 2 +- .../657ca996f3fdf683f408f632.md | 2 +- .../657cad90d6745e85569cdc06.md | 2 +- .../657caec5163c6c85e5b31284.md | 2 +- .../657ccd18f62d4c0292a97808.md | 2 +- .../657ccd8e0b8383034fa1be0b.md | 2 +- .../657ccdeb0919a803c00c8cbd.md | 2 +- .../657ccee0cbd78d044dfe4a77.md | 2 +- .../657cd0e81302a205cfbc10a2.md | 2 +- .../657cd1cdaa5260067b6fb93e.md | 2 +- .../657cd301c8cef107941a5552.md | 2 +- .../657cd5bac0e2df08b433b29d.md | 2 +- .../657cd6c342d0e8093dd5c540.md | 2 +- .../657cd7778a28e4099f0ca6e9.md | 2 +- .../657cd816f3caf509f85e4d4a.md | 2 +- .../657cd8d94290160a8732893d.md | 2 +- .../657cd938cf0b0c0ad751ac23.md | 2 +- .../657cda710736e30ba719e441.md | 2 +- .../657cdf0217569e0ce2e40cd1.md | 2 +- .../657cdfc400c4130d43bab6e9.md | 2 +- .../657ce469dc28f40f4b7ac75d.md | 2 +- .../657ce5caa3e1460ff657c6b0.md | 2 +- .../657ce691d6c57c107e650c5e.md | 2 +- .../657ce7ed5eb7171156711c77.md | 2 +- .../657daa5ab8505427a5b99cd2.md | 2 +- .../657daad61699f1281c5dca55.md | 2 +- .../657dab674b9de728828aa020.md | 2 +- .../657dadfc7d21eb294c9f057e.md | 2 +- .../657df21cc45b1f66112fb8fc.md | 2 +- .../657df2b22d7649667734d71e.md | 2 +- .../657df30a140de766c3896294.md | 2 +- .../657df5d14291b56887825276.md | 2 +- .../657df6018a70e468f5dc016a.md | 2 +- .../657e3ca1c4d9636e9012e1a9.md | 2 +- .../657e3ec58a1c706fb201d719.md | 2 +- .../657e408c387898706d4c1b46.md | 2 +- .../657e4173056b4771208c184d.md | 2 +- .../657e421f8d8e9871a83cda7f.md | 2 +- .../657e428ed1d56c720561e571.md | 2 +- .../657e42d9cf8693725896cc49.md | 2 +- .../657e496dda7af77d6798e7f7.md | 2 +- .../657e49f3ee34e67dbe0d8848.md | 2 +- .../657e4c1f0bd3e97ef2d46644.md | 2 +- .../657e4cd7f87d4f7f6954446d.md | 2 +- .../657e4db2e3fc8d7fb41b8b85.md | 2 +- .../657e4de2c8c70a7ff7e1546d.md | 2 +- .../657e4e3b02a2128049c344c8.md | 2 +- .../657e51218ff18f8191b76ea9.md | 2 +- .../657e523fcaaa0e823b3789e5.md | 2 +- .../657e539471b4aa82c7402c15.md | 2 +- .../657e55e612fac9847dc7ce03.md | 2 +- .../657e56e7034d2d858b6e9e00.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 2 +- .../657f425dbab54e11993c80f0.md | 2 +- .../657732654845d8e2fb1217e6.md | 2 +- .../6554d25dc5ceaa354307a77e.md | 2 +- .../655a2a7210094920069b117c.md | 4 +- .../65560f9380be92226084ef46.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../add-borders-around-your-elements.md | 4 +- .../add-rounded-corners-with-border-radius.md | 4 +- .../basic-css/change-the-color-of-text.md | 4 +- .../change-the-font-size-of-an-element.md | 4 +- ...ive-a-background-color-to-a-div-element.md | 4 +- .../basic-css/import-a-google-font.md | 4 +- ...ke-circular-images-with-a-border-radius.md | 4 +- .../set-the-font-family-of-an-element.md | 4 +- .../basic-css/set-the-id-of-an-element.md | 4 +- .../basic-css/size-your-images.md | 4 +- .../specify-how-fonts-should-degrade.md | 4 +- ...tyle-multiple-elements-with-a-css-class.md | 4 +- .../use-a-css-class-to-style-an-element.md | 4 +- ...use-an-id-attribute-to-style-an-element.md | 4 +- ...e-attribute-selectors-to-style-elements.md | 4 +- .../use-css-selectors-to-style-elements.md | 4 +- .../add-a-submit-button-to-a-form.md | 4 +- .../add-placeholder-text-to-a-text-field.md | 4 +- ...radio-buttons-and-checkboxes-by-default.md | 4 +- .../create-a-form-element.md | 4 +- .../create-a-set-of-checkboxes.md | 4 +- .../create-a-set-of-radio-buttons.md | 4 +- .../create-a-text-field.md | 4 +- .../create-an-ordered-list.md | 4 +- ...ny-elements-within-a-single-div-element.md | 4 +- .../use-html5-to-require-a-field.md | 4 +- ...ibute-with-radio-buttons-and-checkboxes.md | 4 +- .../diff-two-arrays.md | 28 +- .../meet-the-node-console.md | 8 + ...e-of-any-node.js-project-or-npm-package.md | 4 +- .../65576ff7888f9e96f52a4be1.md | 10 +- .../6557709b0aee699a6a00528c.md | 14 +- .../6557712d77ce2d9bd7e63afd.md | 14 +- .../6557716aadbd2d9c42c0e69a.md | 22 +- .../655771d889132f9ccd341060.md | 28 +- .../65577236b056379d5dbc7000.md | 6 +- .../655773b0591c5f9f4045883e.md | 8 +- .../655773f8b8b5db9fc6d0ae76.md | 10 +- .../6557743527cb92a06417ea97.md | 6 +- .../6557746aad2844a0cd864e12.md | 8 +- .../655774955b097ea14897db12.md | 10 +- .../655774d01daeeaa1978b99d5.md | 10 +- .../655775221059f5a20493d5d7.md | 6 +- .../655776db1eeae0a620e42a0d.md | 4 +- .../655777060d8ddea6741be1b1.md | 8 +- .../65577739f57ecca6c39bb4e9.md | 8 +- .../65577791ad8c26a7705e2919.md | 10 +- .../65577a17564ce8a8e06c1460.md | 8 +- .../65578c17d54dfab65cd54b95.md | 8 +- .../65578c74607d40b6d8c4757f.md | 4 +- .../65578cb031cd93b77a285db2.md | 10 +- .../65578cee7f2cb8b80127cce2.md | 6 +- .../65578d0f6c78a0b868a43b9c.md | 10 +- .../65578d4fc3afc3b8f554c882.md | 10 +- .../65578f895f2a65ba7a916804.md | 4 +- .../65578fcf00322dbad5dee05b.md | 8 +- .../655790d113d14dbb727eaf41.md | 8 +- .../6557910b0ebaeebc18209e90.md | 6 +- .../6557913b8fe5c0bc834c9f4f.md | 6 +- .../655791847db8a9bd0b685f40.md | 6 +- .../655791ae44c182bd92f31caa.md | 6 +- .../655791e6cf5e03be3de73451.md | 8 +- .../65579228c669fcbebffd01d5.md | 10 +- .../6557924d47c325bf27afbe51.md | 10 +- .../6557927ad11e58bf8c794b25.md | 8 +- .../6559d70c5161b16ff1d6530d.md | 12 +- .../6559d86fe1b8947954b9178d.md | 10 +- .../6559da1b7d75f088f5e6b89f.md | 6 +- .../6559da93115de78dbbdc7ba3.md | 6 +- .../6566195b0a021bb660b2b4b1.md | 8 +- .../65661b72d6745ebec6a96923.md | 10 +- .../6567722f53ad97d7ea6bb082.md | 6 +- .../65774ae7c3eee66fe79b9459.md | 6 +- .../657891ab9c1903f4e55433ba.md | 6 +- .../65789506b30453080f77470c.md | 16 +- .../6578b13757611e2825beb8a5.md | 8 +- .../6578b57361f2f132a02e2a18.md | 12 +- .../65796fac81f983127558f3f4.md | 8 +- .../6579717f0920131304286804.md | 10 +- .../65797670e0c0d016f17e7660.md | 4 +- .../6579ca0923cfa7162089d2f0.md | 6 +- .../6579cbab9825b8170974c69a.md | 8 +- .../6579cd5f6dd62c189e53ddbb.md | 8 +- .../6579dd49fa8a8e1fd06b85a9.md | 10 +- .../656873ffdc638f7e290f60de.md | 4 +- .../656874efd5102b81815c8ef7.md | 2 +- .../65688f22703200963a85dfb7.md | 4 +- .../65688f737b0ef396bf0c22d6.md | 8 +- .../65688fc27e8dda9760c45d7d.md | 2 +- .../6568904b83a2f29878578146.md | 4 +- .../6568917528820d99236ad811.md | 4 +- .../656896ffecbf07a2d3402a93.md | 6 +- .../6568991b4d4874a4d5271337.md | 4 +- .../656899c0478950a7e5db2cc0.md | 2 +- .../656899f4214ee6a881bc8649.md | 2 +- .../65689a748de8fbaa00c5617e.md | 2 +- .../65689aa3d3f2b6aad204a59e.md | 2 +- .../65689ad61dfa81ab9ffafc86.md | 2 +- .../65689b055e6f49ac6f82d3cf.md | 2 +- .../6568bb1ffe8462c427c0d386.md | 2 +- .../6568bb656c67e9c54cced2d7.md | 2 +- .../6568bba429481cc693fc2570.md | 4 +- .../6568bbc8c3bda1c773e23cf1.md | 4 +- .../6568bc19f3418dc8a8821187.md | 2 +- .../6568bc85c5beadca3e0f6eb1.md | 2 +- .../6568bd3741e379ccc220af1b.md | 6 +- .../6568bd85482755cdd26443ae.md | 4 +- .../6568beebba98a3d1f26f6bf8.md | 6 +- .../6568bf22bb5de0d2e8260cf3.md | 2 +- .../6568bf853bf06dd4ed25d4ca.md | 4 +- .../6568bfb601a54ed5b367b44f.md | 2 +- .../6568bfd65322add674039bde.md | 6 +- .../6568c0013b3b62d7617518c7.md | 4 +- .../6568c024933423d85d5ed93c.md | 4 +- .../6568c073d5f37fd99ab2ab0c.md | 4 +- .../6568c0a5edddc3daa65d20b2.md | 6 +- .../6569d83fe4dcc614c2ff971d.md | 4 +- .../6569d8a4b8d85515cbb1ce72.md | 2 +- .../6569d98303af38193149b66e.md | 4 +- .../6569d9dfd53db11b176d2963.md | 4 +- .../6569da02e7e2641be14ff922.md | 4 +- .../6569de93a5340b202667deda.md | 4 +- .../6569def38470282151f873ce.md | 4 +- .../6569df1d6fb83d22623b38c5.md | 4 +- .../6569df6916294723e01f0035.md | 2 +- .../6569df9e20f74a251d482c5d.md | 2 +- .../6569dffeee007f26d2b56d46.md | 4 +- .../6569e2a01a97b231862ba2ff.md | 4 +- .../6569e2e1944fe7329ab21c7f.md | 2 +- .../6569e309feb5d333867a034a.md | 4 +- .../6569e33a708a3834f6d4879b.md | 4 +- .../6569e37ec28e853628f18a86.md | 4 +- .../6569e3d1418b373839a0aa7b.md | 4 +- .../6569e41657a9923953aa7d3c.md | 2 +- .../6569e481e67f123ad25c5d20.md | 2 +- .../6569f6ebe558bd4136da96cc.md | 4 +- .../6569f70a66ccdc42097ca051.md | 2 +- .../6569f770fd7dc443d6293095.md | 2 +- .../6569f7c7f6954944d207775f.md | 2 +- .../6569fa85d8f9ed49c8dfb37d.md | 2 +- .../6569fbbfee025a4e850b6eaf.md | 2 +- .../6569fc21837cab5029d82e26.md | 4 +- .../6569fc63a404c8519d918095.md | 2 +- .../6569fca3cd7a9f52f322a298.md | 2 +- .../6569fd01dab2ea547d98f093.md | 4 +- .../6569fd352879475599d0ec66.md | 2 +- .../6569fd6d3cb95856c9ed2190.md | 4 +- .../6569fdc59fe1b658bc9e23a4.md | 2 +- .../655cd899f8de09431eabb40c.md | 6 +- .../6564a9fe51964c229d5b7f4c.md | 6 +- .../6564aee9c077774ea49c3faf.md | 4 +- .../656627b47bd2d2a4afbc945d.md | 6 +- .../656680b0fc79f2c38a34d90e.md | 8 +- .../656702f8b4cbd8cbf0a433c6.md | 2 +- .../656707e11e671ed54c96f7ec.md | 2 +- .../656710d1e0ec62253426db24.md | 2 +- .../6569b0a63423f65dd30888df.md | 2 +- .../6569b19d31a09b65b4bc390a.md | 2 +- .../6569b20f829b7e69d43c232a.md | 2 +- .../6569b4e0bd29d17d4b53b16c.md | 4 +- .../6569b5c820a6a1859786e774.md | 2 +- .../6569b68fac723e8c20223ed3.md | 6 +- .../6569b743630ee592a65a7e2f.md | 4 +- .../6569bca4dd9feab7b295a5e1.md | 4 +- .../6569beee367427c90c74899e.md | 2 +- .../6569c05b9166f9d5bb36c09e.md | 6 +- .../6569c166d708dcdf7c8fd34c.md | 4 +- .../6569c2cbf6c993ea8cd85682.md | 2 +- .../65772ef923f922cd720e5008.md | 2 +- .../6577320da0d4c2e594d418e2.md | 4 +- .../6577562501feabdf0984a184.md | 2 +- .../657f3a661730891aa64f3568.md | 6 +- .../6565a536ba1f9f25bd30e88b.md | 8 +- .../656877c202f44995ed952608.md | 8 +- .../656877f71bba2b97acedf9af.md | 12 +- .../656878585631369a6b2d2191.md | 10 +- .../6568789edf2ed39c81983cc4.md | 6 +- .../65687946130b0ea10aa19b75.md | 4 +- .../656879613a96aba21cbe80b9.md | 4 +- .../656879a66338b2a461d5d307.md | 18 +- .../656879c6f35a85a59c06b3a7.md | 8 +- .../656879e1c749d7a6c5eba2d2.md | 4 +- .../65687a005aba3ea815b84e68.md | 6 +- .../65687a8253766cac4c99c57f.md | 4 +- .../65687a923dd792ad339f9c09.md | 4 +- .../65687ad86596e0af38640a84.md | 6 +- .../65687b182c2a8fb1470e0b97.md | 4 +- .../65687b48f2201ab32e06c37c.md | 12 +- .../65687b68003a61b46fe691f0.md | 6 +- .../65687b8eb0bbf7b5d41b610b.md | 6 +- .../65687bbfd9a7d6b78cd5b5cf.md | 8 +- .../65687c2fd0fec7ba9fb8af30.md | 4 +- .../65687c8d86e18cbd775a53c9.md | 8 +- .../65687da2e60409c45595bbe1.md | 6 +- .../65687db6a9fcf3c548a6c1b7.md | 10 +- .../65687dd4b641fdc67d7de487.md | 4 +- .../65687e069cf4e0c85b0a06b1.md | 10 +- .../65687e0ed12e20c91811a48d.md | 6 +- .../65687e294ef2bdca637fb213.md | 6 +- .../65687e457ab1c4cb8c3fe7c8.md | 10 +- .../65687f47f9001dd35bdcd5ab.md | 6 +- .../656880227dab4bd8fbc02d41.md | 10 +- .../6569b831a07d7154c793301b.md | 6 +- .../656b4638cb8bcf2729afe9a9.md | 4 +- .../656b475b394390334828eb12.md | 4 +- .../656b47dc2cf39e37025dc033.md | 4 +- .../656b481ec4976439565a78b2.md | 8 +- .../658212ba98182f3e855e85f9.md | 10 +- .../65821c1c40ccac44adf38e6b.md | 10 +- .../65821fcc010c3245718f2a06.md | 8 +- .../65822308ded1ba4632f66aa3.md | 10 +- .../658225d560369446ece5518b.md | 6 +- .../6582267ef39f5047411c1743.md | 8 +- .../65822773f4c60a479ec89f66.md | 4 +- .../65822934c8a0454803e3ef12.md | 6 +- .../65822bd82d708c4895080c35.md | 8 +- .../65823040bdb32949d4c1a96f.md | 6 +- .../6582324b5d37fe4b622bc3c0.md | 6 +- .../6582352cbdbcde4d0c4f7b0b.md | 8 +- .../65823634a308cb4d6bcc5fa6.md | 10 +- .../658238f7604f154ea9a23e1e.md | 6 +- .../65823b0167fd894f4a7ea60a.md | 10 +- .../65823bbbdb4eaa4f9d20a0fb.md | 4 +- .../65823cfc74aa564ffc460489.md | 4 +- .../65823dde36392f505a39f7c7.md | 4 +- .../65823e87c9741750a22085a7.md | 6 +- .../65823ff0d4b991510fade1a8.md | 6 +- .../65824111a09164518320088d.md | 10 +- .../658244fdf4b0265334711664.md | 4 +- .../65824561f3478e5371a33ae5.md | 8 +- .../658246c28575d653d1f89b59.md | 8 +- .../65824872894f59546e3084e2.md | 6 +- .../65824a1b16631c54fa524154.md | 6 +- .../65824c7b4e2da85597693dcf.md | 10 +- .../65824dfdb6815d563b2d3256.md | 8 +- .../6582507654b3ed5712341382.md | 12 +- .../658252f6b1526d57b103d48a.md | 6 +- .../658254db6e12485a48130f57.md | 8 +- .../658255d5f955175b270f251d.md | 6 +- .../6582575b8089f85b8b92d7c8.md | 14 +- .../658258c0e5fbe85c14c060cf.md | 10 +- .../65825a9520a0795c8afbef50.md | 6 +- .../65825b758fe85a5cebabc8c5.md | 10 +- .../65825cda2668995d5168e37c.md | 6 +- .../65825e96b5db5f5dee6bf57c.md | 6 +- .../6582601b2987045e8e7da994.md | 6 +- .../6582622cb6c11a5f4c5d79b4.md | 6 +- .../6582687859366a618424d84b.md | 10 +- .../65826a6e9d189a623141c726.md | 6 +- .../65826af5b226a5628aa154b1.md | 6 +- .../65826befd75db5632bd73df6.md | 14 +- .../657e928716b77b2277980276.md | 10 +- .../657ed53c19461d4b95c4757a.md | 8 +- .../657ee28cefc4945568287673.md | 8 +- .../657ef2a86d4e545cec9a85fb.md | 10 +- .../657efa642593c5746acc5c81.md | 12 +- .../657efce98e958b75df86b305.md | 6 +- .../657efdcf7fe23b76c0cff9ec.md | 6 +- .../657effaa2a5e0277d71f9cbe.md | 6 +- .../657f0044be09db790b1eb1c5.md | 10 +- .../657f01ae9aea647b27402d3e.md | 4 +- .../657f025ec86c3d7c4177b6be.md | 4 +- .../657f0353c9523d7d896873ea.md | 8 +- .../657f04ed0035f47ed04d0f1f.md | 8 +- .../657f28a0482132aca51a9212.md | 6 +- .../657f425dbab54e11993c80f0.md | 12 +- .../657f4345abe7f2161f99f1ad.md | 6 +- .../657f43d341a0dd17120cdb08.md | 10 +- .../657f456223b8c1187b461987.md | 10 +- .../657f465f8e718b19c5105ae5.md | 12 +- .../657f47b12c51e41b3149e584.md | 8 +- .../657f4a4a5828a01de04b652f.md | 6 +- .../657f4add33ea4b1f61ba3dc8.md | 10 +- .../64dc8b1faf9c60304ca8a9b6.md | 12 +- .../64dc8ea01436383a88256d7f.md | 12 +- .../64dc9004f658183afa85f4f1.md | 8 +- .../64dc90949ff85e3b37be40d0.md | 8 +- .../64dc90e837670a3ba26a1e61.md | 4 +- .../64dc916138dbe03bdfe6cec6.md | 12 +- .../64dc922df2919e3c38cead61.md | 8 +- .../64dc92a9718fb53ca3d1bad7.md | 10 +- .../64dc963d866fff3dd0329993.md | 4 +- .../64dc97005bc7943e2978df0a.md | 8 +- .../64dc976bf864693e668d67e8.md | 6 +- .../64dc97ab25730b3e9de86ea5.md | 8 +- .../64dc985e6720a23edac63b51.md | 8 +- .../64dcd3d61c448e2676501f43.md | 10 +- .../64dcd9bbc2268127e7898d77.md | 10 +- .../64dcdee07a14f0299ec30559.md | 8 +- .../64dce7ee2494e82bf4205a3f.md | 4 +- .../64ddcc2ee182e0164c3539f8.md | 8 +- .../64ddce6f6e8066173208235b.md | 4 +- .../64ddd02838f36117cd9738eb.md | 2 +- .../64ddd280d69fa818ca782d50.md | 4 +- .../64ddd65848a12919d7e1c7d0.md | 2 +- .../64de1469fccce61940f498c4.md | 16 +- .../64de4bccf5becb208a48ca97.md | 16 +- .../64de6c8a5305d8173a3a9e09.md | 6 +- .../64de7357cc75bd18bdced920.md | 6 +- .../64de73f6c2486518e3064fec.md | 6 +- .../64de7662244db513d7b673ec.md | 6 +- .../64de773f81facd14653f49c8.md | 2 +- .../64de79de2fac6b1536ebcfdd.md | 4 +- .../64de7be06eb689161dd63cf0.md | 2 +- .../64df202aa1342114cd077920.md | 8 +- .../64df332162988b13c35b7f7d.md | 4 +- .../64df346f4c86461419974c1e.md | 8 +- .../64df353d7ae6dc148fd64f53.md | 8 +- .../64df3e2fac34d813d048f3f9.md | 8 +- .../64df3f1011888113fbd3d81b.md | 4 +- .../64df45a3ad4f8719e5355244.md | 2 +- .../64df47b32b92301a815d5ef8.md | 4 +- .../64df496c6a8ddf1b38db1ed6.md | 6 +- .../64df72c6e0183a191fcd72dc.md | 4 +- .../64e337e3096b7c1739d934e6.md | 2 +- .../64e3392996b41d17a1375643.md | 4 +- .../64e33a488b4a2717fa22ebf3.md | 6 +- .../64e340302bd28513f3e73740.md | 6 +- .../64e340ecee18af1430939018.md | 2 +- .../64e34146860065146733883b.md | 4 +- .../650c6082e5586f9e3acfcd3b.md | 8 +- .../65782342850feb3b8d62f936.md | 8 +- .../6578273de26b6e5965a9107d.md | 6 +- .../657b667a772ed53e82962c81.md | 4 +- .../657b6a4a49faec5c600287ba.md | 2 +- .../6564642ce403fe29cc23fee7.md | 6 +- .../6564683821b2ee3174e7250e.md | 12 +- .../656469e62377ab34a5bcb8d1.md | 12 +- .../65646ab6bced52360f44670f.md | 6 +- .../65646ffeaed2d238c562a014.md | 6 +- .../656470d517833a39bb8b5608.md | 8 +- .../656474314bf37d3c83a85143.md | 8 +- .../656475bbf1c2573de1d2c69c.md | 12 +- .../656477845006313fbfea0ad1.md | 6 +- .../656479aa5f298441c190bf8f.md | 4 +- .../65647c71a5d2bd431596f629.md | 6 +- .../656485a8a3496d4a36b1496a.md | 8 +- .../6564883669b5af4b69f794cc.md | 6 +- .../656489e0a5d0954c1a64fc93.md | 4 +- .../65648e4c5b316c4ec5e4fddc.md | 4 +- .../65648eefbee2014f5815f4ba.md | 4 +- .../65648f4b2281ba50051ae39c.md | 8 +- .../656490295d346850a4c4f2b5.md | 4 +- .../65649122c7f77f519aaf0975.md | 8 +- .../656491fa4e69005287eb5a9a.md | 6 +- .../656494269ccce754411a2112.md | 6 +- .../65649a631440b757f9f7b428.md | 12 +- .../6564a767a7241362f7d8d664.md | 8 +- .../6564b8c9349bd76dc037967b.md | 12 +- .../6564c67db26c417561ab510d.md | 10 +- .../6564cbb6311a40783b3f5de6.md | 6 +- .../6564cf2e8642517abdf9d6e2.md | 6 +- .../6564d096a55d707bd77ab67b.md | 8 +- .../6564d27c8e4c197d367c3b1c.md | 6 +- .../6564d2eeb36ebe7dd9bd1ee9.md | 6 +- .../6564d500f1a48e7f2b732a37.md | 6 +- .../6564d68c34027a8072a704f4.md | 6 +- .../6564d75a923d21815caaa445.md | 8 +- .../6564d97a5ef99783216a6229.md | 8 +- .../6564daa2725b9b8420141b1c.md | 4 +- .../6564db880cf9408535f17ff4.md | 6 +- .../6564dd65c3c2fa873a83d213.md | 8 +- .../6564de10a0887f882b0012d3.md | 8 +- .../6564eebf0d2d6390b9377197.md | 6 +- .../6564efa70114b591b74d5679.md | 8 +- .../6564f0279e23ce924eedd1b2.md | 10 +- .../6564f32b18480893cf7799fd.md | 6 +- .../6564f583ca6fbf9556098dd6.md | 4 +- .../6564f834dd717998092cfd47.md | 6 +- .../6564fd78ffff909b1531d3c3.md | 4 +- .../6565012a2564509d40a90048.md | 6 +- .../6565bb128adfcd5ec362382d.md | 6 +- .../6565bd4265158360de8e2ae7.md | 6 +- .../6565c014db6e9b63c257771d.md | 6 +- .../6565c084627071646f94c4b0.md | 6 +- .../6565c13fdb798865c161d8f8.md | 6 +- .../6565c234de8cdf673c96bdf3.md | 6 +- .../6565c32f89ab8d68b42aff30.md | 4 +- .../6565c3a146bd5469b62bc59e.md | 4 +- .../6565c4767f49286aec825c6d.md | 6 +- .../656eec2f40d18056cc58b229.md | 8 +- .../656ef54070c72161e6feb90f.md | 8 +- .../656ef5bc5c0cd464be1df675.md | 8 +- .../656ef783bba6976de014eaa8.md | 4 +- .../656ef7f792734072dedd8319.md | 6 +- .../656ef89b4b486b7a16077864.md | 10 +- .../656f04b20397d9a574cc7eb2.md | 8 +- .../656f0bc259c1f6b57486ed68.md | 8 +- .../656f0d6bc60b58b9777a36c9.md | 8 +- .../656f10458134d4c4e283a2f1.md | 6 +- .../6577319039f4f7de9251b822.md | 10 +- .../657732654845d8e2fb1217e6.md | 8 +- .../6577333feab1e8e927014f03.md | 8 +- .../657733bc97eb83efdb7e3988.md | 4 +- .../657dadf4d8b93c1704f3a57c.md | 8 +- .../657db2114b4029241956f5d6.md | 4 +- .../657db4cb77190e33a20e852a.md | 6 +- .../6551f1e8737dbe6e0cb08ea4.md | 6 +- .../6551f22653e6ce6e4f1d1370.md | 8 +- .../6551f3bfed58796ebb1268dc.md | 4 +- .../6551f4259d66026ee28cb205.md | 4 +- .../6551f5756c20146fc94f8675.md | 10 +- .../6551f6f9ec6db270eb83f3db.md | 10 +- .../6551fb531ce7f773071a0b84.md | 4 +- .../6551fe3b1df7c9740f13f270.md | 14 +- .../6552008c0d9d9075cbec9772.md | 14 +- .../655208d59b131e7816f18c96.md | 8 +- .../655209a4a27dd37873c4cac3.md | 8 +- .../65520e6f2b9678799977f24d.md | 6 +- .../65520f8282faf57a0db4f7fe.md | 4 +- .../65521203d7165c7b84b22ad4.md | 18 +- .../65521fc818947e800bffe48a.md | 4 +- .../655220953ba90d80514d7ee2.md | 6 +- .../65522255d5b9cd80f335c6f2.md | 4 +- .../6552487e689f6e895f658717.md | 6 +- .../65524b3aa6a1938a069a91ab.md | 6 +- .../65524b790ba8558a2f1c9fe5.md | 4 +- .../65524d2a1a253b8bb5197ae2.md | 6 +- .../655251308f31958d06cdf267.md | 2 +- .../65525e359ca28d938baa82c5.md | 8 +- .../655261b2e1f2c197093f3993.md | 10 +- .../6553980e0527fa115c705646.md | 4 +- .../6553995f412dd8122ed38e4a.md | 10 +- .../6553a44b1801991847d8cc69.md | 4 +- .../6553a572f7a65718f1e42e18.md | 14 +- .../6553a755879b131a445e664c.md | 4 +- .../6553a7d8d05cbb1ae335a665.md | 8 +- .../6553ed69ece88d29594748aa.md | 6 +- .../6553efd6ada3f42aa2d75448.md | 8 +- .../6553f3fc92741c2bf8ded140.md | 2 +- .../6553f4f66099802c6ae94613.md | 6 +- .../6553f6086add4b2cbb99fd78.md | 8 +- .../6553f6b4ec51112d44d737c8.md | 4 +- .../6553f8c570f9982e013a8886.md | 6 +- .../655491bd5b98b813fa5bedca.md | 6 +- .../6554930320d70414e7b6acc6.md | 4 +- .../65549561463f0016876e852c.md | 2 +- .../65549f90cf78131c96ebcf28.md | 8 +- .../6554a334a40edb1fb4eff827.md | 2 +- .../6554a49a4f782f208abcc87e.md | 4 +- .../6554a57ec0a2c52106e7ee50.md | 4 +- .../6554a88d5af937226f4a9121.md | 6 +- .../6554ac937a49be2701af4f2f.md | 4 +- .../6554ad2463b8892748f8efdd.md | 10 +- .../6554d0332949b133a0b35eaa.md | 6 +- .../6554d15c8acb5f34499ad789.md | 4 +- .../6554d25dc5ceaa354307a77e.md | 8 +- .../6554de295ade563a069936a1.md | 4 +- .../6554dfce1683be3c0c9609a6.md | 4 +- .../6554e0adc7bb193cbfdb36d5.md | 10 +- .../6554e2ee23bfd93f2c83640f.md | 4 +- .../6554e343caea913ffba7bec6.md | 6 +- .../655516e410b8e30fb4fb64e8.md | 6 +- .../65551a628bcb7e121e32d04b.md | 8 +- .../6555201d9b7fc917399f9f0b.md | 4 +- .../655520c20cb1e6177b0641d6.md | 6 +- .../655522883e66f618e03a9411.md | 4 +- .../6555231eac4d9f19bd3d44b5.md | 8 +- .../65552a111190e11f0963949e.md | 4 +- .../65552a9593755e1fb2f5ab50.md | 8 +- .../65552b14e803731fe3c1e4ca.md | 6 +- .../65553159615a8123b190ee43.md | 8 +- .../6555d6e12c95701172b55709.md | 6 +- .../6555d8b0b3d20b128bdadd37.md | 4 +- .../6555db4a7b788e15795674e5.md | 6 +- .../6555df0c81300b175308557d.md | 4 +- .../6555e1bfcd374e18c6be8e58.md | 8 +- .../6555e3f387381a19d5e00333.md | 4 +- .../6555e43e783ed31a0532b1b2.md | 6 +- .../6555e547c18a2b1a7b795bd8.md | 4 +- .../6555e5991af57d1ae0e35f0a.md | 8 +- .../655619327c7b364166f8dd6f.md | 6 +- .../655a2a7210094920069b117c.md | 32 +- .../65687d2f8c7ee27b0446cef3.md | 6 +- .../656883980318048fb11a6e3b.md | 4 +- .../656884439d4d7d929d58669d.md | 8 +- .../656886ec4e4d9b96ded3c565.md | 6 +- .../65688a50e6c998a21d8e41d3.md | 8 +- .../65688b5a1655a7a6caede847.md | 6 +- .../6568b7a40c7ba0ccbc4b4425.md | 6 +- .../6568c86dc9193000d11ca5e0.md | 2 +- .../6568cc9301a0c41058ed95c5.md | 6 +- .../659526f3e5424b3eac4b6aa7.md | 4 +- .../65952b70924edb449faf1950.md | 4 +- .../659530ca823d6c47f61daa8a.md | 4 +- .../659db3e3670d3e712be82593.md | 8 +- .../65a450e8fb2c9d75c7378d28.md | 10 +- .../65a51c9e000b660122b8b29e.md | 4 +- .../65560f9380be92226084ef46.md | 4 +- .../65560ffdb7d05d248e012280.md | 2 +- .../65561022956c1024e7184add.md | 6 +- .../655a10e4a620fc091ba43b3d.md | 2 +- .../655a1188d6cfbb0a3ec63c57.md | 4 +- .../655a11eb4e54b60acd6bd641.md | 2 +- .../655a12c2ab0bcc0c2ba30e16.md | 2 +- .../655a13744e82580d7ee3073d.md | 4 +- .../655a13aa8af2510de51f2e1c.md | 6 +- .../655a142ae611b30e5df0ac16.md | 2 +- .../655a1479ba7e7c0ee6c1acdd.md | 4 +- .../655a151cc6041f0ff7d24ded.md | 4 +- .../655a153a6b362d103e125028.md | 2 +- .../655a1564f3aa8210938cdf68.md | 2 +- .../655a158c7e80c810f6eff1e1.md | 2 +- .../655a15b683445611528cccf1.md | 2 +- .../655a167ea3e96512bf1343ce.md | 2 +- .../655a16db1ccc5e132b5bc44d.md | 2 +- .../655a173e5b8adc13b761ed74.md | 4 +- .../655a194276dfa11460f7b5e3.md | 2 +- .../655a1a6d8c44db154b00c909.md | 2 +- .../655a227e57aabb25d1f9c987.md | 6 +- .../655a44442b60ee5a28df8ee5.md | 4 +- .../655a452d40556e5c25e4aac8.md | 2 +- .../655a45c52fa3ea5ece3034c7.md | 2 +- .../655a4614304cd36031cb4e75.md | 4 +- .../655a46aa8e10c26218c5034c.md | 4 +- .../655a46fce0ce5a638c180e36.md | 2 +- .../655a4761e1a40065fc4d3712.md | 4 +- .../655a47a9404d856743c7f529.md | 2 +- .../655a482dfc92896901b9c97e.md | 2 +- .../655a489d83b1996bd537b153.md | 4 +- .../655a48da2c25656d2f7bab4d.md | 2 +- .../655a493ab909a96f7c316cd5.md | 2 +- .../655a4ffc762d117470b94e3b.md | 4 +- .../655a50f992ba7177aff2b718.md | 2 +- .../655a515f4b85ce79464fe5e8.md | 2 +- .../655a51a705c97d7a9294ab2a.md | 2 +- .../655a51ff908edc7c12c3a92c.md | 2 +- .../655a523d4bbc8b7d3848d7dd.md | 4 +- .../655a52bca925967fa2336190.md | 2 +- .../655a536e99be288210f01451.md | 4 +- .../655a5489c62889851c60ff4b.md | 2 +- .../655a54cd88e33b8646c67e16.md | 2 +- .../655a54fd97ada88722fa5c8b.md | 2 +- .../655a552337ee62882fdeee79.md | 4 +- .../655a557104bb878962e2ae95.md | 2 +- .../655a5637ad283d8d24dd49de.md | 4 +- .../655a56a6a1168a8f201ba666.md | 2 +- .../655a577302a8a791ed62e8d9.md | 2 +- .../655a585b87885d962f715a10.md | 4 +- .../655a59607b0d2e9b0f5d69e5.md | 2 +- .../arithmetic-formatter.md | 213 ++++- .../budget-app.md | 846 +++++++++++++++++- .../polygon-area-calculator.md | 828 ++++++++++++++++- .../probability-calculator.md | 234 ++++- .../time-calculator.md | 569 +++++++++++- ...d-a-new-element-to-a-binary-search-tree.md | 2 +- .../data-structures/depth-first-search.md | 2 +- .../remove-an-element-from-a-max-heap.md | 71 +- .../5f3ef6e056bdde6ae6892ba2.md | 2 +- .../build-a-cash-register.md | 46 +- .../build-a-palindrome-checker.md | 66 +- .../build-a-pokemon-search-app.md | 62 +- .../build-a-roman-numeral-converter.md | 42 +- .../build-a-telephone-number-validator.md | 132 +-- .../6350854411ffb73feb6bb84e.md | 2 +- .../635085f80bd9b5429faa40c4.md | 4 +- .../6350866cce4c6d43bdf607c8.md | 2 +- .../63508750f040a348a440a0bf.md | 2 +- .../635089e3bd3e144f2db4094f.md | 4 +- .../63508bb4afb069534e81f33b.md | 2 +- .../635091f8dbf554575fb5aa0c.md | 2 +- .../6352e93db104661305c5f658.md | 2 +- .../6352ea3a5b79e614ee2282fd.md | 2 +- .../6352ee566a59d31d24bde74b.md | 2 +- .../6352f09b1e53a420e7873344.md | 4 +- .../6352f2526dccb523150b64fb.md | 4 +- .../6352f2a24eb71b24284ca2b6.md | 2 +- .../6352faf71a9db52631864634.md | 4 +- .../6352fbb93a91a8272f838d42.md | 4 +- .../6352fcb156834128001ea945.md | 2 +- .../6352fe473d53592a40ae403b.md | 6 +- .../6352fed209792d2b89e92ea1.md | 2 +- .../6353024f5eab012fa2f57eec.md | 2 +- .../6353028147d3c7309017216a.md | 2 +- .../643c14c8027369027334e802.md | 2 +- .../643c337176a83407d0cd915c.md | 2 +- .../643c359312d030093352fe41.md | 4 +- .../643c565936a10109b3f59326.md | 4 +- .../643c8d9a73965c0a26d7f634.md | 2 +- .../643c90830bbeb40ab15148a6.md | 6 +- .../643ee973c162ae017b3d30db.md | 6 +- .../64440a50d076c204051f2cc0.md | 2 +- .../6407c6a2c2159309994779a5.md | 2 +- .../6410e70c84bb660b4d2a5ea1.md | 8 +- .../6410edb33eeaf50dd9a22ab4.md | 8 +- .../6410efff0ae97c0f06856511.md | 2 +- .../6410f149110ec60fd40fcfe1.md | 4 +- .../6410fcd1f731fd17cdb101a7.md | 8 +- .../6411024727181d190ef03166.md | 8 +- .../64110727cefd3d1d9bdb0128.md | 2 +- .../64110998bc00321fd8052ab5.md | 4 +- .../641110e4fb696b259dbf0bcf.md | 2 +- .../6411135e9ee2fa26c882eb02.md | 2 +- .../64112c9cf53d632910ea2f9b.md | 2 +- .../64112cea9e6ac22a314628b0.md | 2 +- .../641130423e5f512d8972dae1.md | 2 +- .../64113124efd2852edafaf25f.md | 2 +- .../62a3b3eab50e193608c19fc6.md | 2 +- .../62a3b41c9494f937560640ab.md | 4 +- .../62a3c8bf3980c14c438d2aed.md | 4 +- .../62a8a929e4260d08093756d2.md | 4 +- .../62a8b1762b7775124622e1a3.md | 2 +- .../62a8b3cc436db8139cc5fc09.md | 2 +- .../62a8b6536156c51500739b41.md | 4 +- .../62a8c4db0710f3260f867a92.md | 2 +- .../62a8cbd1e3595431d5a2b3f1.md | 2 +- .../62a8d24c97461b3ddb9397c8.md | 4 +- .../62a8dd9cdb16324b04cfd958.md | 4 +- .../62a8dfcf7fb1044d2f478fd1.md | 4 +- .../62aa1eec891ed731db227a36.md | 2 +- .../62aa20e9cf1be9358f5aceae.md | 4 +- .../62aa22aba186563bcbf2c395.md | 2 +- .../62ba17beef16c563069a65d8.md | 2 + .../63ec3287b182ec0efe8a3135.md | 50 +- .../63ec3427fc3e9214c9ed2a14.md | 12 +- .../63ec36f6133df7160be3ec66.md | 12 +- .../63ec47b454495519739486a7.md | 12 +- .../63ee5d38a5d29d0696f8d820.md | 12 +- .../63ee5d8f9e7168076e932fe2.md | 12 +- .../63ee5e0f08e82208364c4128.md | 12 +- .../63ee5ea8be892e0955ab346c.md | 12 +- .../63ee5fc113bcb20a5db9214b.md | 12 +- .../63ee611d478dca0b77f6a393.md | 12 +- .../63ee7c664f9b65137d925c8a.md | 12 +- .../63eea5cea403a81a68ae493c.md | 12 +- .../63eea817673c8e1c22927fa6.md | 14 +- .../63eea8e1e143ae1d098c8c9d.md | 12 +- .../63eeb8e86becbf1e75c2cb0d.md | 12 +- .../63eedebb0ec0231ff1cede1a.md | 12 +- .../63efdbc22a0c56070beabed7.md | 12 +- .../63efe370bbfc4a08d500118e.md | 12 +- .../63eff02f00e69a0b2ac10b43.md | 12 +- .../63eff98ffb1d5a0d24ec79cb.md | 12 +- .../63effe558c87a70e7072e447.md | 12 +- .../63f0165121a9181342d5bc66.md | 12 +- .../63f017b4ad028a148eb713c0.md | 12 +- .../63f01861f813e01564c95315.md | 12 +- .../63f018f04e487e164dc27bd9.md | 12 +- .../63f01c9791a0aa1751c73760.md | 12 +- .../63f0224ceb16dc196d2c860a.md | 12 +- .../63f026d041bc6c1a3d5cba0f.md | 12 +- .../63f0284532742c1b26c7a052.md | 12 +- .../63f0289df84a581bbdbd29b7.md | 12 +- .../63f0295e673b661ccb299e8a.md | 12 +- .../63f029b96b9e9e1df93be951.md | 12 +- .../63f02a4ef92d711ec1ff618c.md | 12 +- .../63f02b22cce1c11fe9604381.md | 12 +- .../63f02bdeb9b428208b97eb6b.md | 12 +- .../63f02c6e18773921ba50aa53.md | 12 +- .../63f0311f5ea9382388d6124f.md | 12 +- .../63f033fdb1fbcc254999fcc3.md | 12 +- .../63f03446c2ed3e264be6c7fc.md | 12 +- .../63f0348a54a177272071a595.md | 12 +- .../63f034d012f74627ce538d3a.md | 12 +- .../63f03686c5ea863533ec71f4.md | 12 +- .../63f036ec91fdf238c90665f5.md | 12 +- .../63f0370b340915399d31e5eb.md | 12 +- .../63f0374d5351223a747c301d.md | 12 +- .../63f0378e173e3c3b7638b528.md | 12 +- .../63f038a0ae041d3c5b0cdf23.md | 12 +- .../63f038e671d3f73d5a041973.md | 12 +- .../63f039dbcef7673e4e758fa3.md | 12 +- .../63f03a7143a6ef3f7f3344f0.md | 12 +- .../63f03ac2b428b2404a5a7518.md | 12 +- .../63f03af535682e4138fdb915.md | 12 +- .../63f03b1ed5ab15420c057463.md | 24 +- .../63f6721d5110af243ef8f3d9.md | 12 +- .../652f948489abbb81e6bf5a01.md | 30 +- .../652fa2aee6374ad29b5d49b4.md | 30 +- .../652fa3c4968fa9d6f8f6d873.md | 16 +- .../65327e9c7ea42e125256b29a.md | 4 +- .../653281af14be5f2055310f8e.md | 6 - .../653283d07b8f9d294aafa83b.md | 30 +- .../65362bfd67d61d517deef191.md | 32 +- .../653635c731206b718659d3d5.md | 34 +- .../653639d63a45a077333312c8.md | 30 +- .../653641509b6e7681a9333245.md | 30 +- .../65364566e84e378837fbaf2a.md | 34 +- .../653fb19b515fde28243f727a.md | 27 +- .../65420dcfc60580678dad7a92.md | 4 +- .../654215fe7b4a899ddceb3b60.md | 4 +- .../65422ba173a18b1bedef1bb6.md | 34 +- .../6552127b2576c2fbc5ecc2ea.md | 32 +- .../65521badc7b7470edf952372.md | 30 +- .../65521ec3bb117c195c4f6cb5.md | 32 +- .../655220a3fa5c3c200bc8e938.md | 34 +- .../6552303a9a78704f8ff072e9.md | 32 +- .../655235c2e607297f00316650.md | 36 +- .../6552385244ccf89b77d6b332.md | 30 +- .../655243068222c2c1166b90b0.md | 32 +- .../655476e1ff522252fdcce5e4.md | 34 +- .../655479aa3e1e0360ae38b7a6.md | 34 +- .../65547ee197840478a1b95f4b.md | 32 +- .../6554815fe2472f8bfdab7642.md | 30 +- .../655482742cc5499726e3f347.md | 34 +- .../655483ebf0096ba02b2c3d4c.md | 34 +- .../655485321913feabbc5f00f8.md | 32 +- .../6554860ea4dfbab2f4786fc8.md | 30 +- .../655487f686aabfc2a10ba887.md | 28 +- .../65548f747a4cdafd186948d1.md | 34 +- .../655490f55c36900779336988.md | 32 +- .../655492e6b90c7a198c587943.md | 28 +- .../655494d5a15d6a2567e1ea60.md | 28 +- .../655495a6bd96e42bc3baa795.md | 30 +- .../6555d17af9ff06a14d399f6d.md | 38 +- .../6555d458687cb3b357834df9.md | 36 +- .../6555d729c9bfd7c3195f1948.md | 36 +- .../6555d7e384056dc9c581fadf.md | 30 +- .../6555d8faed60b9d3e4a6cefb.md | 30 +- .../6555dd138e70cae6b546966d.md | 30 +- .../6555de565387a2efe90a6ccc.md | 34 +- .../6555e04aeb225bfbae237344.md | 30 +- .../6555e0bfe4d69904410f7cd3.md | 30 +- .../6555e39a5f4c6f138c7d9405.md | 32 +- .../6555e57d3e6d9d221c4735be.md | 32 +- .../6555e6cec786da2aadc11ea0.md | 38 +- .../6555e7acdbae972d3e8e0f5b.md | 36 +- .../6555e9197bf1d7416bdd76e0.md | 30 +- .../6555ebf07ec610585a626f72.md | 30 +- .../65571e742fbf4532d8f98e90.md | 36 +- .../655720534347cb3f31cdfb3d.md | 28 +- .../65572399a8e16d50bc2c1ff3.md | 36 +- .../655724bac464795a0ad91082.md | 28 +- .../655727b2e1e49d6adf584442.md | 36 +- .../655729e68e49b277a6b448bd.md | 38 +- .../65572bb34a7e488224b937fc.md | 32 +- .../65572e5aaf022790fb4a81b1.md | 32 +- .../655737cd004591b0271d6826.md | 30 +- .../65573a97c59ddbbf028ca95e.md | 40 +- .../65573d0abe4d38cd6fa13f44.md | 40 +- .../6557421eb6a7a0f0500e3106.md | 30 +- .../655b49333d9f265bc1512152.md | 34 +- .../655b4bbff1dbf66cb2ed4dac.md | 32 +- .../655b4c8f636d9675953a0388.md | 38 +- .../655b4dad1d38ff7cdd65cbfe.md | 64 +- .../655dc43318591b975cdfe2d8.md | 8 +- .../65606d06666e118ba86162be.md | 8 +- .../65606ed6ea2baca053327e9b.md | 8 +- .../656071d679089ebd9d5035a0.md | 10 +- .../656472ed8f552d2f2b3f7883.md | 34 +- .../6567055f59d39f07d1c542dc.md | 2 +- .../65671421254eeb489875cdd8.md | 30 +- .../65672136535209761a5cf02b.md | 26 +- .../65672adafbaa37a6cef886f7.md | 38 +- .../659b0093d7db5a1a1122b7bd.md | 30 +- .../65a608b7e7c75a04ccf0c23c.md | 10 +- .../65a6098a3405f206312e28f5.md | 14 +- .../65a609f6e23f3b06c608fb57.md | 16 +- .../65a60aa3efd8fa079c2d1537.md | 24 +- .../65a60b0b8b4f96085ac23463.md | 28 +- .../65c64fe6c770a22db893e931.md | 643 +++++++++++++ .../65c6532520cf4f323329b2c6.md | 653 ++++++++++++++ .../65cf1f2cd796c06057bf3f3c.md | 648 ++++++++++++++ .../641da3c6b6fbd742bff6ee40.md | 2 +- .../641da42481d90c4314c99e94.md | 2 +- .../641da465273051435d332b15.md | 2 +- .../641da4b16937be43ba24c63d.md | 2 +- .../641da51a9810e74411262fcc.md | 12 +- .../641da5462576784453146ec2.md | 4 +- .../641da5abaac81844a54adb03.md | 2 +- .../641da615af82bf454215a992.md | 2 +- .../641da6570acf7545931ce477.md | 2 +- .../641da73b09e7f046c758e0ed.md | 4 +- .../641da791d0c34a472b8d15b6.md | 4 +- .../641da7bfbc7f0f477438ad8a.md | 6 +- .../641da8db2a036048ebe6999e.md | 4 +- .../641da9aceb788e49a73ebcc9.md | 2 +- .../641daa5ea050f24a7cade6e6.md | 4 +- .../641daae5e18eae4b562633e4.md | 4 +- .../641dab13c1b6f14b9828e6b1.md | 2 +- .../63c9bcc26219e7090da0f549.md | 4 +- .../63c9e45519caf31b987fbb5f.md | 2 +- .../63c9e5eea8261d22856ead1c.md | 2 +- .../642dccb78549c9285835ebc2.md | 12 +- .../642df32c0c2db433d8b46d46.md | 2 +- .../6434750c53db16218f41e6e1.md | 4 +- .../6434759f78ec812264ff8f34.md | 10 +- .../643498755d54c6279ba09078.md | 8 +- .../6437124c4c03dd4c8fb35d56.md | 4 +- .../6437133052eaf04d7300e622.md | 6 +- .../643715013330824ecaa70442.md | 14 +- .../64496d1e5af8c0148fbef96d.md | 10 +- .../64496d80bc174a158c973080.md | 18 +- .../64496e9c6d7a2e189948e441.md | 4 +- .../6449755666005520330cec5b.md | 6 +- .../64497da4062602213ecf32e7.md | 14 +- .../64497de936a2f322327e5c58.md | 6 +- .../64497e0e5e5a2c2329785af4.md | 2 +- .../6449842c6f6c84261075e4c9.md | 14 +- .../64498473a17adc26ef0ecc2d.md | 2 +- .../6449849b78f43527be1e8a98.md | 12 +- .../64498542cab69128ab24e4de.md | 12 +- .../6449860d84c9e22cbd7b497c.md | 2 +- .../6449863f592af72d9be0959e.md | 10 +- .../6449874d5191562eb3313b3f.md | 6 +- .../6449876e7aae0d2f8257a497.md | 18 +- .../64498b085028fc30a58bb6a7.md | 10 +- .../646d0889c6ff4baa46ac1c50.md | 12 +- .../646d09a07241aaab1e777080.md | 6 +- .../646d0a022da7bcabf3e3aca3.md | 10 +- .../646d0d20108440acc95a6b32.md | 6 +- .../646d0db5175974ad8633b71c.md | 4 +- .../646d0e4636e14eae2bb3b992.md | 8 +- .../646d1980018efaaec2b1c28b.md | 8 +- .../646d19fc4705e4af65c3e688.md | 4 +- .../646d1b96dd7ea4b0061458bc.md | 4 +- .../646d1cadf0d96ab0b7e12da4.md | 4 +- .../646d1d67f9261fb15a795588.md | 8 +- .../646d1e531042dfb24da1f032.md | 4 +- .../646d3141790b3cb337dd611a.md | 8 +- .../646d382c4d70ceb3dba1e830.md | 8 +- .../646d386a685620b49db4be76.md | 4 +- .../646d38c326f3c8b54023de38.md | 4 +- .../646d38f906b94cb5fe6ce7de.md | 4 +- .../646d3952f6af37b6a1c241c2.md | 2 +- .../646d39c156fe94b7482c3ab6.md | 16 +- .../646d3b27cd3c56b875256301.md | 14 +- .../646d3bc75fe0c9b972da3323.md | 8 +- .../646d3f718b5f8dc102cd528e.md | 6 +- .../646d404259f512c1a9e86ac1.md | 22 +- .../646d40c543943ec250039682.md | 10 +- .../646d40fe4b7b50c30c2b4cd8.md | 12 +- .../646d41e23b583fc3b8cc4579.md | 6 +- .../646d423fade4a9c4636acd13.md | 8 +- .../646d42f58deb2fc52adc6611.md | 22 +- .../646d43587d926bc5b6cb2e50.md | 10 +- .../646d448479c8fdc8dcec868c.md | 8 +- .../646d44da986f2bc9b72f5fe2.md | 22 +- .../646d451c2e44afca71b67818.md | 14 +- .../646d4554721d43cb19a68bc4.md | 10 +- .../646d45b739da5ecbf830c108.md | 8 +- .../646d45ee725632cca2555146.md | 8 +- .../646d4626420eeecd51f241c2.md | 16 +- .../646d467c6994f4ce0dc416a4.md | 12 +- .../646d46c03e7d02cecb30f021.md | 10 +- .../646d4717a689e1cfa232e357.md | 16 +- .../646d4769ba65f1d05ef6b634.md | 8 +- .../646d47c8f58107d10f1e5106.md | 8 +- .../646d4813c17b37d1e261a566.md | 8 +- .../646d486aec20f7d2a581cc36.md | 4 +- .../646d48b936802fd34c3f05af.md | 10 +- .../646d498c8ebc31d3f753b22e.md | 2 +- .../646d49bfff9079d4b38df115.md | 2 +- .../646d4a07a8fb14d55cd70e09.md | 2 +- .../646d4a5b32a1cad6165df286.md | 2 +- .../646d4a8dbc04c6d6bb0001f8.md | 2 +- .../646d4ab9b3b4c5d74fdd2154.md | 2 +- .../646d4b3d80ea98d824c8a4f9.md | 4 +- .../6491d38f5b09a021c4b5d5fe.md | 2 +- .../6579fc66adaabbca6ceddb1f.md | 2 +- .../657a018ddd0006ce5bc29fa4.md | 2 +- .../657ca764afcc5221ee01f1a9.md | 2 +- .../657caf204c0d672a35411c31.md | 4 +- .../657ccb8022b59543d2e391b7.md | 2 +- .../657cd762ea9e6a47c459ee8b.md | 4 +- .../657cf2b586b3495a69394d7c.md | 2 +- .../657cf677438e705eab9fd1f9.md | 8 +- .../657cfad68610a4654bb171f4.md | 2 +- .../657d301f80931609b9a5d110.md | 2 +- .../657d374ef92a36145abdd215.md | 8 +- .../657d397542d1a2162407ac39.md | 2 +- .../657e09d4802a136e868a7f5e.md | 2 +- .../657e0c2c6a9d37705146f34d.md | 10 +- .../657e21575e71e2822f3b0abd.md | 2 +- .../657e230500602983e01fff6e.md | 8 +- .../657e253cf2c01685ed84c1ee.md | 4 +- .../657e2bac662a3c8f5801d550.md | 2 +- .../657e390964da9f9bff8f3625.md | 2 +- .../6482b4fef5fd6bcdfddad730.md | 8 +- .../6482bc5d699f0acfc52bdc41.md | 10 +- .../64861a8856e1eaf9e349570e.md | 8 +- .../64861c02ff1ef4fa62a9e132.md | 65 +- .../6486212f80701cfb18052eae.md | 14 +- .../64862530b093dbfbea58f43d.md | 26 +- .../6486282ca3a469fca6ebed27.md | 16 +- .../649a6b393a10a4357087b3f7.md | 16 +- .../649a75a844f2ea3a0060d807.md | 16 +- .../649a80aa4405823b3f81a47f.md | 16 +- .../649a845dccffd93c0d41ad4b.md | 16 +- .../649a88458b4e343fbdffbbc0.md | 16 +- .../64a1d39230e33585f3dd0dae.md | 16 +- .../64a1d86b1294b2869cef1c18.md | 16 +- .../64a1e1b74d2e4e019acb70b8.md | 20 +- .../64a1e54abad976028a8938f1.md | 16 +- .../64a1fdbf48e08b06e8b05870.md | 16 +- .../64a2cadabc8538152c49a7eb.md | 16 +- .../64a2ceb58fe10e15e0dc223f.md | 18 +- .../64a2d19c5029ba166cb912e5.md | 16 +- .../64a2d5f23518e71727cac0db.md | 18 +- .../64a2d86799a58517c29f79a5.md | 20 +- .../64aaf2aff7f1fc7a550f40cb.md | 20 +- .../64aaf83d46b16a7b20a27051.md | 20 +- .../64ab0134716d0a7c8889f167.md | 20 +- .../64ab06a9cc033b7d4a8bad2a.md | 20 +- .../64ab143edad72b7e25b23f8a.md | 20 +- .../64ab178206f3237eafcc0ef4.md | 20 +- .../64acebecb7484c8c6a760534.md | 20 +- .../64aced3e88b0a38cec824dea.md | 20 +- .../64acedb5f59c0c8d43e96aa4.md | 20 +- .../64acf1af380a708ded8761f0.md | 20 +- .../64acf287857bb38e6dd7ca69.md | 28 +- .../64c703f58330b3767399e486.md | 24 +- .../64c705fd8969d677066792b8.md | 32 +- .../64c708fe06b0c3776f90faaf.md | 28 +- .../64c70d3bf7504978368da6ad.md | 24 +- .../64c70f78dbf5667a307a7d90.md | 24 +- .../64c71235eba6c67adaa9a458.md | 30 +- .../64c7135a9d35797b4bfb01b3.md | 24 +- .../64c714ec1b844f7bc0723deb.md | 24 +- .../64c715769bab5f7c14f6cd7b.md | 24 +- .../64c7168cba4a4f7c90c26277.md | 24 +- .../64c7173772c2497ce99b474c.md | 24 +- .../64c7202620a5e17d8a3c777d.md | 24 +- .../64c72e52133d687e8e6a60f6.md | 24 +- .../64c73367cce78a7fd65dd3be.md | 24 +- .../64c734293def73808e609778.md | 24 +- .../64c736a531835181349c27d2.md | 24 +- .../64c73981de025581bddb89eb.md | 24 +- .../64c73df1424422832333a9fa.md | 24 +- .../64c74a226587f502c0525927.md | 24 +- .../64c74a8a4138c6032241d498.md | 24 +- .../64c74c293dd7cf03cbd58194.md | 24 +- .../64c74e0064a9080443af0796.md | 28 +- .../64c750c328e06f0878a9272e.md | 26 +- .../64c7527100b19b09037ce5db.md | 26 +- .../64c7538db3e33d09704ab148.md | 26 +- .../64c754f598ca5409d0a08884.md | 32 +- .../64c755bf0034b20a428a4a1b.md | 34 +- .../64c7561d44e2300a90a38ab6.md | 74 +- .../64c7573fd2265f0b1c77e2ec.md | 50 +- .../64c758ab7352130b775df8c4.md | 50 +- .../64c764dd9071050d0a2c1473.md | 56 +- .../64c9bab6998128282da063f9.md | 50 +- .../64c9db021d4d912906878f3a.md | 54 +- .../64c9dc4bd63a92295347c449.md | 54 +- .../64c9e4cc5f06902dc75dc8f4.md | 52 +- .../64c9e90c433fde2e870285a3.md | 50 +- .../64c9efea385ca536bf467a7c.md | 50 +- .../64c9fa51209ab5395d524cce.md | 50 +- .../64c9fe7b2ffa3539fbf82d32.md | 50 +- .../64cab4d06512c95234256cbb.md | 52 +- .../64caea41a4199e54253c60ca.md | 50 +- .../64caeb134c3cdc5498cd75b9.md | 50 +- .../64caeeae2fa57756035d6012.md | 50 +- .../64caf1be15606d5814c3387b.md | 50 +- .../64caf237baef43587be6d860.md | 50 +- .../64cb24c224ac2c61fa1c70aa.md | 50 +- .../64cb262dd91ecc62998736af.md | 52 +- .../64cb26e84dd0b56313ba0c6e.md | 56 +- .../64cb2a87057eb5655c66d1c2.md | 54 +- .../64cb2da32f8443669fd4e725.md | 64 +- .../64cb2e5bdfb23a67272a07c7.md | 61 +- .../64cb2ff0c31b0f67a6d76a47.md | 71 +- .../64cb30b8e4719a67fe14f364.md | 76 +- .../64cb34c01b3d856a9a59261d.md | 70 +- .../64cb3f62b10c336bada1c70c.md | 92 +- .../64cb472593e3be6d10a7c13b.md | 66 +- .../64cb480723790d6d727b8ef5.md | 66 +- .../64cb48e36c9ad56dd7a523f4.md | 68 +- .../64cb4978631a4f6e3e1b964d.md | 66 +- .../64cb4e676c156f7332f40db7.md | 66 +- .../64cb4ebdc75b3a73a43da5ec.md | 66 +- .../64cb50fd95831a745ea60d13.md | 72 +- .../64cb522509ffb274daf9fd9e.md | 68 +- .../64cb583dadb33a77595797bd.md | 70 +- .../64cb5d1d48532b79b4e7ef6c.md | 76 +- .../6507512fe521de40085b8831.md | 75 +- .../650755908a8071409ab9e09e.md | 75 +- .../650756e20cffbe41305a0dde.md | 77 +- .../650757918a9e97418dc3d71a.md | 146 +-- .../65afeb7ab6867b43dacbf32b.md | 187 ++++ .../65afec8f02423144ef136a94.md | 183 ++++ .../65b006efc74c675c2bdfccba.md | 223 +++++ .../65b00a6f1c429c5e9fa50e90.md | 219 +++++ .../65b2a465d7ca3ab6e902285b.md | 388 ++++++++ .../65b2bb4c279af3cd585ba777.md | 443 +++++++++ .../64e4e4c4ec263b62ae7bf54d.md | 12 +- .../64e4e6c86954de67a3e44ee3.md | 12 +- .../64e4e6fe78b5aa67ef2fc3e7.md | 12 +- .../64e4e7241f52bb682eeb8211.md | 8 +- .../64e4ebc7eabc5a6babd479cd.md | 4 +- .../64e4ecd7735a566c9266a338.md | 2 +- .../64e4eec13546c06d61a63d59.md | 2 +- .../64ec8f717b261e824d82d6a5.md | 2 +- .../64ec9282cd547785258cecf2.md | 2 +- .../64ec94f0de20c086e09b0fc3.md | 4 +- .../64ec959a76336c8767f5cd4d.md | 4 +- .../64ec96761156a187ed32b274.md | 6 +- .../64fac365aeb8ad70b69b366f.md | 8 +- .../64fac4d1773e7a719b1254de.md | 2 +- .../64fac6a497811572b338e5e5.md | 4 +- .../64faca774fd9fd74bc084cc9.md | 2 +- .../64facf6180824876f70a2e86.md | 6 +- .../64fad07f43a101779cb8692a.md | 2 +- .../64fad9cd2eeb1e7ca2ca8c8b.md | 2 +- .../64fadae4f2d51b7d5d8b98d8.md | 2 +- .../64faf0418e828c0114a558a7.md | 2 +- .../64faf65b22ad8d07df9be14d.md | 2 +- .../64faf874364ec308f875f636.md | 4 +- .../64fb0fa0968f2b113b2d90e9.md | 2 +- .../64fb1321e189a6136d200f77.md | 6 +- .../64fb1436adef3e145b4c3501.md | 2 +- .../64fb14d890415c14f93069ce.md | 2 +- .../64fb154a7c48cd159924bb18.md | 4 +- .../64fb1c4dc0feb219149a7c7d.md | 15 +- .../64fb29348a60361ccd45c1e2.md | 2 +- .../64fefebad99209211ec30537.md | 2 +- .../64ff0313700dad264d19dfe4.md | 4 +- .../64ff04cc33779427a6412449.md | 4 +- .../64ff068e0426eb288874ed79.md | 2 +- .../64ff23daf176a92de95f24dc.md | 4 +- .../64ff24b80431f62ec6b93f65.md | 2 +- .../65003986d17d1e1865b269c0.md | 2 +- .../650046832f92c01a35834bca.md | 2 +- .../65004ba581d03d1d5628b41c.md | 2 +- .../65099dbd8f137d58e5c0ff16.md | 4 +- .../659ebe52d74b132a1d75c891.md | 4 +- .../63c620161fc2b49ac340ffc4.md | 2 +- .../63cf7e324c1831f8d936b3ae.md | 2 +- .../63cf7f97e7f99af9348f5068.md | 2 +- .../63cf812bb8ecd4f9cf749b8f.md | 2 +- .../63cf8ec006a776ff5f6e3c68.md | 4 +- .../63cf90d4696d8f00851873a4.md | 2 +- .../63cf93472de77d01bf8474bf.md | 4 +- .../63d1214a0ac7a9389793269b.md | 4 +- .../63d128eaedcc773d2ded2128.md | 4 +- .../63e949b8327aa2aca2ca8eac.md | 2 +- .../63e954321b0a77ae4f6d9650.md | 4 +- .../63e95e39860dc5b01ebe9be0.md | 4 +- .../63e9718d7d490bb3940d5a0a.md | 2 +- .../63f28972973504e7bb58b0b3.md | 4 +- .../63f2a0a860790eebe61bf908.md | 4 +- .../63f2a4a8087e6dec8ec47f16.md | 12 +- .../63f2a5f09a785aed155c0a56.md | 10 +- .../63f2a8e14fb388edd3242527.md | 10 +- .../63f2aa36fcdc63ee4e18fc37.md | 10 +- .../641fcfd468185384ac218b7d.md | 2 +- .../64005ab13a78eb062547c12d.md | 2 +- .../644760f4fb15ce765baebb62.md | 2 +- .../6448b2c9aec64c0ecd41573d.md | 4 +- .../6448fefcd6445d6b3d9d63db.md | 2 +- .../644b765b3bf09e6dff5e0931.md | 2 +- .../644b7ac994d7dd73a61b4fa6.md | 2 +- .../645b5c05986aba539ba6ca03.md | 2 +- .../645b65b681a62f5fa125ff62.md | 4 +- .../645b9d56b48971997a8055dd.md | 2 +- .../645b9de38df75b9a5cfc2e85.md | 4 +- .../645b9ea45d3a9a9d711df81a.md | 2 +- .../645cb07132281a380223e458.md | 2 +- .../645cb1306eb27a397be7f18c.md | 2 +- .../64646bc0e5a60ea131e03f91.md | 2 +- .../64646db2c684b7a3a174a1d0.md | 2 +- .../646477c82475ffaf0c3c0771.md | 2 +- .../6464905afec9efcf7328ce58.md | 2 +- .../641cdebe67ec0f25a4798356.md | 2 +- .../641cdefa704f232675ed98aa.md | 6 +- .../641cdf57c3f7ee276e1d9b32.md | 20 +- .../6421f98f4999d1179ce37cb4.md | 8 +- .../65388ac7154e44b72c74d616.md | 2 +- .../65388bbcbf6928b83fc424d1.md | 4 +- .../65388edfdf364fbb04e426f2.md | 6 +- .../653898fa7eee37c57b960e35.md | 2 +- .../65389a63d3b1d6c764c0e10e.md | 6 +- .../top-build-a-recipe-project.md | 2 +- .../introduction-flexbox-question-b.md | 2 +- .../introduction-flexbox-question-c.md | 5 +- .../introduction-flexbox-question-e.md | 2 +- .../introduction-flexbox-question-j.md | 2 +- .../introduction-flexbox-question-k.md | 2 +- .../html-foundations-question-a.md | 2 +- ...earn-variables-and-operators-question-a.md | 3 +- ...earn-variables-and-operators-question-b.md | 3 +- ...earn-variables-and-operators-question-c.md | 1 + ...earn-variables-and-operators-question-d.md | 1 + ...earn-variables-and-operators-question-e.md | 17 +- ...earn-variables-and-operators-question-f.md | 1 + ...earn-variables-and-operators-question-g.md | 3 +- ...earn-variables-and-operators-question-h.md | 27 +- ...earn-variables-and-operators-question-i.md | 1 + .../the-box-model-question-b.md | 6 +- .../the-box-model-question-c.md | 4 +- .../the-box-model-question-d.md | 5 +- .../the-box-model-question-g.md | 4 +- .../5daa813381b9e3db6c126b43.md | 8 + .../65df3afd233057f6a620a860.md | 53 ++ .../657cb542baf74594933c7ac9.md | 8 +- .../657cb5dd956a8797462da793.md | 6 +- .../657ce0bbf16c312c8dcc8dff.md | 2 +- .../655c0feadb1dd77f6cda623f.md | 228 ++++- .../657b0f0be03b2137ed88b36c.md | 50 +- .../657b106ced8c653be6b3218f.md | 50 +- .../657b108cf870283d22b21e8e.md | 50 +- .../657b110ad8afcc3f8e586362.md | 50 +- .../657b115008a62d41c0d7482f.md | 47 +- .../657b119f0ce64343420bb850.md | 47 +- .../657b11e082e48a44eb4bfc09.md | 52 +- .../657b11f87368cf463ea4fe46.md | 50 +- .../657b1240ef768447b80817ad.md | 49 +- .../657b12ae08dd7049b300c901.md | 47 +- .../657b12e7c306334b7c320221.md | 51 +- .../657b13088693ef4ce21ce0e4.md | 47 +- .../657b133afcef714e542b557a.md | 47 +- .../657b135e9029fb4f8141e40c.md | 85 +- .../657b138d33db9e50f116b5f0.md | 50 +- .../657b1431076b365555784189.md | 47 +- .../657b145976723b56a97b8dda.md | 59 +- .../657b149630b3ea5873269a38.md | 47 +- .../657b14d8353d665a187fe771.md | 69 +- .../657b153ac677705c7059530d.md | 50 +- .../657b15dbcafe4d5f39a5de82.md | 50 +- .../657b160d6a8662610fe6a523.md | 58 +- .../657b163c9da40e62b904be1f.md | 50 +- .../657b18e71067d6680b9ac5d3.md | 52 +- .../657b1985ae17886b05b382b1.md | 52 +- .../657b19bf7b32af6caf763ef7.md | 50 +- .../657b1a03df3ec46eca276046.md | 50 +- .../657b1a27dc6daf6ffd52ff1f.md | 76 +- .../657b1a637e4dc571f8f4d3d7.md | 47 +- .../657b1a9581015573806e1e20.md | 58 +- .../657b1cc072206e7ac3db88b8.md | 51 +- .../657b1d080265ba7c4f96bf79.md | 50 +- .../657b1d4ec0e2587e8bcc95f7.md | 336 ++++++- .../657b1da0b27fef8117827ce5.md | 62 +- .../657b1dfec76149836ea5c7d0.md | 50 +- .../657b1e2fad2ffe84ab420a56.md | 59 +- .../657b1e66159fec86336a737b.md | 50 +- .../657b1e9a62603587747f7f45.md | 1 - .../657b1ee1de7216896b5b4361.md | 79 +- .../657b1f0585d48f8ac0b19654.md | 77 +- .../657b1f598f63008c8bdb20b8.md | 1 - .../657b1f981cd42e8dc3b282d9.md | 1 - .../657b1fe950c0df90346e5d12.md | 58 +- .../657b201372864e91d4f5bb53.md | 49 +- .../657b20338e0802931673c1e1.md | 2 - .../657b20985d315095e5c3851d.md | 62 +- .../657b21e28a01039cb27b4f13.md | 2 - .../657b221b2ab0ac9e18a173ef.md | 1 - .../657b223e41ce6b9f9a01d214.md | 49 +- .../657b227f7ad32ea17e2cdf28.md | 223 ++++- .../657b2310b8cd52a4f15c1818.md | 75 +- .../657b2340be1593a6517fe77b.md | 49 +- .../657b236aa1eb9fa7b209aa03.md | 50 +- .../657b23a413d28da927e087ca.md | 45 +- .../657b23bc0e32f9aa9c62eb82.md | 46 +- .../657b23f03b449aac2c517089.md | 3 - .../657b242d06512dadaea55056.md | 1 - .../657b24542024c8af092cd6c4.md | 49 +- .../657b24774d8cdab052ffe2a6.md | 61 +- .../657b24a500800cb1c6945da9.md | 61 +- .../657b2be1b19500c63fc1a467.md | 59 +- .../657b2c040bb5f6c77fa5df80.md | 50 +- .../657b2d618b8851cc5baf9490.md | 46 +- .../657b2d9cb974dace59024964.md | 50 +- .../657b2dd7745fdcd03e5160f4.md | 201 ++++- .../657b2e0666d4a9d1b851f90e.md | 50 +- .../657b2ec6c054efd71e503a27.md | 1 - .../657b2eeb31e435d89ecce6f3.md | 1 - .../657b2f0b3bcfe7d9f4151854.md | 50 +- .../657b2f3bf7a2cbdb58d959d5.md | 47 +- .../657b2f6cb66826dcbac08094.md | 47 +- .../657b2fa89ddc20de629ca21f.md | 50 +- .../657b2fc9c0f96bdfddfce4d9.md | 50 +- .../657b2fea728c2be14a8a98c4.md | 47 +- .../657b3026ff79fbe2dda6cb39.md | 50 +- .../657b306fe94f29e4b4aa9105.md | 49 +- .../657b30ac03b523e6640deaf1.md | 75 +- .../657b30e1b9f035e7e656fd01.md | 50 +- .../657b315533e4edeba65111b8.md | 50 +- .../657b46c9be150f577f5a1086.md | 246 ++++- .../6579c5fb3e65fd9cb85253a5.md | 15 + .../6579c82fc81196a43686415a.md | 39 + .../6579c8d3313c5fa61d25d4ff.md | 39 + .../6579c96067f16bad8e7e6cba.md | 55 ++ .../6579cee11b0bd1cc8bf20829.md | 41 + .../6579cf3ada08bdcfd5eae689.md | 54 ++ .../6579cf81a9cec6d21f872959.md | 47 + .../6579cfc55663f6d40c4a65e1.md | 54 ++ .../6579d002683211d5c7d13ef3.md | 54 ++ .../6579d035f49339d7aa16ec74.md | 39 + .../6579d06801111dd95231e7e5.md | 54 ++ .../6579d40e7729a7e393cfcdd3.md | 39 + .../6579d44bd49d1ae58c2603d4.md | 54 ++ .../6579d49319613ee79fe12f7d.md | 39 + .../6579d4ca0578b4e95f1df60e.md | 54 ++ .../6579d4f3afd265eb0db874f7.md | 48 + .../6579d539b1e5c2ec64484e49.md | 54 ++ .../6579d56623c2d8ee0f2bea87.md | 54 ++ .../6579d58e434920ef874f2502.md | 50 ++ .../6579d62a28ab37f24f6ea8f9.md | 52 ++ .../6579d67a4c6a3bf5d55ce3fd.md | 54 ++ .../6579d7f5a745c0fac805d356.md | 54 ++ .../6579d827ebd50afcacb829fe.md | 54 ++ .../6579d84f48c9c2fe53b06de9.md | 39 + .../6579d86fee9092ffb268f962.md | 39 + .../6579d89bc117c40111641200.md | 54 ++ .../6579d8d24bf33b02f22685ac.md | 54 ++ .../6579db53194a7c0f617943ac.md | 39 + .../6579db734a2b8010c3e92ada.md | 55 ++ .../6579db9c67d64e123b19c235.md | 54 ++ .../6579dbc2c1fc601436f2676b.md | 39 + .../6579dbf6a3e8a5161a592169.md | 54 ++ .../6579dc4332b86017e39b9c03.md | 73 ++ .../6579dce8bc44981add67eda9.md | 15 + .../6579dd420cf6b81db05470f4.md | 39 + .../6579dd5f2f35b11f3dcd9702.md | 54 ++ .../6579dd80bdd49220560f26ad.md | 54 ++ .../6579dd9846f35921af1ffe1c.md | 54 ++ .../6579ddb17d88c12323aae5b5.md | 38 + .../6579ddc94db61d2463022da3.md | 54 ++ .../6579dde808b24525c95ec2a3.md | 31 + .../6579de040244fb274179f001.md | 39 + .../6579de1f43444d2869022c6d.md | 54 ++ .../6579de444ec34929dbc6c2ab.md | 47 + .../6579de58f1da5a2b4c6ea741.md | 54 ++ .../6579de73144df42cb2d373ef.md | 54 ++ .../6579de90a68c532e08e96f02.md | 39 + .../6579df1646568c3268b93637.md | 78 ++ .../6579df5f24a43034dbe456f1.md | 15 + .../6579dfac25b3e6370956a820.md | 55 ++ .../6579dfd504a9ad385a3a4fd9.md | 55 ++ .../6579e0385253cd3a7bd44902.md | 46 + .../6579e08f06692a3c176f3faa.md | 54 ++ .../6579e0e6402c813da7e25ca2.md | 54 ++ .../6579e102b5a7223f0d0e9fc4.md | 47 + .../6579e12834045640e90e58bd.md | 47 + .../6579e13cd2c9ee424eb815df.md | 54 ++ .../6579e153639adb43c017f3d3.md | 47 + .../6579e17ff05c5d451c2e4f35.md | 54 ++ .../6579e19be475334667ba4333.md | 39 + .../6579e1b324902e47dae63c90.md | 54 ++ .../6579e1cd6c8b6248fa62ed48.md | 96 ++ .../657e00b8edd9c338225cbce5.md | 2 +- .../657e06eca8147f561619be7d.md | 2 +- .../657e270fae538dd663360e65.md | 4 +- .../657e29a26f65fae11f8721f8.md | 2 +- .../657e2c02a685f4ec9ec951ff.md | 2 +- .../657e3228f9f24007a7d59779.md | 2 +- .../rosetta-code-challenges/execute-brain.md | 11 +- .../factors-of-a-mersenne-number.md | 16 +- 9250 files changed, 209325 insertions(+), 52285 deletions(-) create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/arabic/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/arabic/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/chinese-traditional/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/chinese-traditional/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/chinese/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/chinese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/espanol/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/espanol/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/german/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/german/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/italian/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/italian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/japanese/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/japanese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/korean/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/korean/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/portuguese/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/portuguese/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/swahili/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/swahili/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md create mode 100644 curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md create mode 100644 curriculum/challenges/ukrainian/20-upcoming-python/learn-python-by-building-a-blackjack-game/65df3afd233057f6a620a860.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c5fb3e65fd9cb85253a5.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c82fc81196a43686415a.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c8d3313c5fa61d25d4ff.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579c96067f16bad8e7e6cba.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cee11b0bd1cc8bf20829.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf3ada08bdcfd5eae689.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cf81a9cec6d21f872959.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579cfc55663f6d40c4a65e1.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d002683211d5c7d13ef3.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d035f49339d7aa16ec74.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d06801111dd95231e7e5.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d40e7729a7e393cfcdd3.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d44bd49d1ae58c2603d4.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d49319613ee79fe12f7d.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4ca0578b4e95f1df60e.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d4f3afd265eb0db874f7.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d539b1e5c2ec64484e49.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d56623c2d8ee0f2bea87.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d58e434920ef874f2502.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d62a28ab37f24f6ea8f9.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d67a4c6a3bf5d55ce3fd.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d7f5a745c0fac805d356.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d827ebd50afcacb829fe.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d84f48c9c2fe53b06de9.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d86fee9092ffb268f962.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d89bc117c40111641200.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579d8d24bf33b02f22685ac.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db53194a7c0f617943ac.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db734a2b8010c3e92ada.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579db9c67d64e123b19c235.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbc2c1fc601436f2676b.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dbf6a3e8a5161a592169.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dc4332b86017e39b9c03.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dce8bc44981add67eda9.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd420cf6b81db05470f4.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd5f2f35b11f3dcd9702.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd80bdd49220560f26ad.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dd9846f35921af1ffe1c.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddb17d88c12323aae5b5.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579ddc94db61d2463022da3.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dde808b24525c95ec2a3.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de040244fb274179f001.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de1f43444d2869022c6d.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de444ec34929dbc6c2ab.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de58f1da5a2b4c6ea741.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de73144df42cb2d373ef.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579de90a68c532e08e96f02.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df1646568c3268b93637.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579df5f24a43034dbe456f1.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfac25b3e6370956a820.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579dfd504a9ad385a3a4fd9.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0385253cd3a7bd44902.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e08f06692a3c176f3faa.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e0e6402c813da7e25ca2.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e102b5a7223f0d0e9fc4.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e12834045640e90e58bd.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e13cd2c9ee424eb815df.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e153639adb43c017f3d3.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e17ff05c5d451c2e4f35.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e19be475334667ba4333.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1b324902e47dae63c90.md create mode 100644 curriculum/challenges/ukrainian/21-a2-english-for-developers/learn-how-to-share-your-progress-in-weekly-stand-up-meetings/6579e1cd6c8b6248fa62ed48.md diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-borders-around-your-elements.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-borders-around-your-elements.md index 0aa95c6af1f..425dcfade1b 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-borders-around-your-elements.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-borders-around-your-elements.md @@ -103,7 +103,7 @@ assert($('img').css('border-left-color') === 'rgb(0, 128, 0)');

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -165,7 +165,7 @@ assert($('img').css('border-left-color') === 'rgb(0, 128, 0)');

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-rounded-corners-with-border-radius.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-rounded-corners-with-border-radius.md index 3e24a525849..2d3899fc209 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-rounded-corners-with-border-radius.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/add-rounded-corners-with-border-radius.md @@ -76,7 +76,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -139,7 +139,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-color-of-text.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-color-of-text.md index 7057023cd31..1ec9e8ca660 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-color-of-text.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-color-of-text.md @@ -61,7 +61,7 @@ assert($('h2').attr('style') && $('h2').attr('style').endsWith(';'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -97,7 +97,7 @@ assert($('h2').attr('style') && $('h2').attr('style').endsWith(';'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-font-size-of-an-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-font-size-of-an-element.md index bbd64626de7..afb836e7614 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-font-size-of-an-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/change-the-font-size-of-an-element.md @@ -49,7 +49,7 @@ assert(code.match(/p\s*{\s*font-size\s*:\s*16\s*px\s*;\s*}/i));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -94,7 +94,7 @@ assert(code.match(/p\s*{\s*font-size\s*:\s*16\s*px\s*;\s*}/i));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/give-a-background-color-to-a-div-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/give-a-background-color-to-a-div-element.md index aad5fc61870..b7b6171a119 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/give-a-background-color-to-a-div-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/give-a-background-color-to-a-div-element.md @@ -84,7 +84,7 @@ assert(code.match(/\.silver-background\s*{\s*background-color\s*:\s*silver\s*;?\

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -151,7 +151,7 @@ assert(code.match(/\.silver-background\s*{\s*background-color\s*:\s*silver\s*;?\

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/import-a-google-font.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/import-a-google-font.md index 7448cf89e1a..a909ea63fc0 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/import-a-google-font.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/import-a-google-font.md @@ -98,7 +98,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -150,7 +150,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/make-circular-images-with-a-border-radius.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/make-circular-images-with-a-border-radius.md index a419b2eb155..da0755abb7a 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/make-circular-images-with-a-border-radius.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/make-circular-images-with-a-border-radius.md @@ -70,7 +70,7 @@ assert(code.match(/50%/g));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -134,7 +134,7 @@ assert(code.match(/50%/g));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-font-family-of-an-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-font-family-of-an-element.md index 7361b23ca9a..2c86fe60b57 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-font-family-of-an-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-font-family-of-an-element.md @@ -60,7 +60,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -107,7 +107,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-id-of-an-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-id-of-an-element.md index f836a375a02..71bd9432593 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-id-of-an-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/set-the-id-of-an-element.md @@ -78,7 +78,7 @@ assert($('form').attr('id') === 'cat-photo-form');

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -145,7 +145,7 @@ assert($('form').attr('id') === 'cat-photo-form');

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/size-your-images.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/size-your-images.md index 5276825a2a7..7659eeeeb11 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/size-your-images.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/size-your-images.md @@ -74,7 +74,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -130,7 +130,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/specify-how-fonts-should-degrade.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/specify-how-fonts-should-degrade.md index d026745ce7d..f794f3c3270 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/specify-how-fonts-should-degrade.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/specify-how-fonts-should-degrade.md @@ -95,7 +95,7 @@ assert(new RegExp('[^fc]-->', 'gi').test(code));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -147,7 +147,7 @@ assert(new RegExp('[^fc]-->', 'gi').test(code));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/style-multiple-elements-with-a-css-class.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/style-multiple-elements-with-a-css-class.md index 4fbb6004bc7..b9bda6782e3 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/style-multiple-elements-with-a-css-class.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/style-multiple-elements-with-a-css-class.md @@ -66,7 +66,7 @@ assert($('p:eq(0)').hasClass('red-text'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -108,7 +108,7 @@ assert($('p:eq(0)').hasClass('red-text'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-a-css-class-to-style-an-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-a-css-class-to-style-an-element.md index 5e146068bc7..08bd13ce465 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-a-css-class-to-style-an-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-a-css-class-to-style-an-element.md @@ -75,7 +75,7 @@ assert($('h2').attr('style') === undefined);

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -117,7 +117,7 @@ assert($('h2').attr('style') === undefined);

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-an-id-attribute-to-style-an-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-an-id-attribute-to-style-an-element.md index e8e58a92159..ef08af64c77 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-an-id-attribute-to-style-an-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-an-id-attribute-to-style-an-element.md @@ -101,7 +101,7 @@ assert(!code.match(//gi) && !code.match(//gi));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -172,7 +172,7 @@ assert(!code.match(//gi) && !code.match(//gi));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-attribute-selectors-to-style-elements.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-attribute-selectors-to-style-elements.md index 219cf8699b6..1043402edff 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-attribute-selectors-to-style-elements.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-attribute-selectors-to-style-elements.md @@ -114,7 +114,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -185,7 +185,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-css-selectors-to-style-elements.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-css-selectors-to-style-elements.md index a56e9494f24..d32b43c5714 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-css-selectors-to-style-elements.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-css/use-css-selectors-to-style-elements.md @@ -92,7 +92,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -133,7 +133,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-a-submit-button-to-a-form.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-a-submit-button-to-a-form.md index 25f446b403d..86d1c232b19 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-a-submit-button-to-a-form.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-a-submit-button-to-a-form.md @@ -68,7 +68,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -95,7 +95,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-placeholder-text-to-a-text-field.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-placeholder-text-to-a-text-field.md index e0d1425d5f1..6c8d43576a3 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-placeholder-text-to-a-text-field.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/add-placeholder-text-to-a-text-field.md @@ -68,7 +68,7 @@ assert($('input[type=text]').length > 0);

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -93,7 +93,7 @@ assert($('input[type=text]').length > 0);

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/check-radio-buttons-and-checkboxes-by-default.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/check-radio-buttons-and-checkboxes-by-default.md index a096fcbeeec..41b2790477f 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/check-radio-buttons-and-checkboxes-by-default.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/check-radio-buttons-and-checkboxes-by-default.md @@ -60,7 +60,7 @@ assert.equal(document.querySelector('label[for="loving"]')?.innerText?.trim(), '

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -93,7 +93,7 @@ assert.equal(document.querySelector('label[for="loving"]')?.innerText?.trim(), '

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-form-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-form-element.md index 8ab63d7a071..db74fab53a6 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-form-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-form-element.md @@ -64,7 +64,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -89,7 +89,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-checkboxes.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-checkboxes.md index 6c0f2f8caeb..52ef0e822ba 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-checkboxes.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-checkboxes.md @@ -80,7 +80,7 @@ assert($('label').parent().get(0).tagName.match('FORM'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -110,7 +110,7 @@ assert($('label').parent().get(0).tagName.match('FORM'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-radio-buttons.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-radio-buttons.md index 3a1fb4e602b..37cd3e3300a 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-radio-buttons.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-set-of-radio-buttons.md @@ -112,7 +112,7 @@ assert($('label').parent().get(0).tagName.match('FORM'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -140,7 +140,7 @@ assert($('label').parent().get(0).tagName.match('FORM'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-text-field.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-text-field.md index 27b4210292e..b3629bf5484 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-text-field.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-a-text-field.md @@ -46,7 +46,7 @@ assert($('input[type=text]').length > 0);

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -72,7 +72,7 @@ assert($('input[type=text]').length > 0);

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-an-ordered-list.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-an-ordered-list.md index 2684bfe9035..3e323922c3d 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-an-ordered-list.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/create-an-ordered-list.md @@ -123,7 +123,7 @@ $('ol li').each((i, val) =>

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -143,7 +143,7 @@ $('ol li').each((i, val) =>

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/nest-many-elements-within-a-single-div-element.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/nest-many-elements-within-a-single-div-element.md index fb6f0ea966f..0c0cdc1f6f0 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/nest-many-elements-within-a-single-div-element.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/nest-many-elements-within-a-single-div-element.md @@ -63,7 +63,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -97,7 +97,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-html5-to-require-a-field.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-html5-to-require-a-field.md index d4d2b233d01..5a9a3ba732f 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-html5-to-require-a-field.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-html5-to-require-a-field.md @@ -40,7 +40,7 @@ assert($('input').prop('required'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -68,7 +68,7 @@ assert($('input').prop('required'));

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-the-value-attribute-with-radio-buttons-and-checkboxes.md b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-the-value-attribute-with-radio-buttons-and-checkboxes.md index 79dbae43b43..e9f5815e88e 100644 --- a/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-the-value-attribute-with-radio-buttons-and-checkboxes.md +++ b/curriculum/challenges/arabic/01-responsive-web-design/basic-html-and-html5/use-the-value-attribute-with-radio-buttons-and-checkboxes.md @@ -92,7 +92,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
@@ -125,7 +125,7 @@ assert(

Things cats love:

    -
  • cat nip
  • +
  • catnip
  • laser pointers
  • lasagna
diff --git a/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md b/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md index b4d2ec80dd6..0b66ffc57fa 100644 --- a/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md +++ b/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/diff-two-arrays.md @@ -168,22 +168,26 @@ diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]); ```js function diffArray(arr1, arr2) { + if (arr1.length === 0) return arr2; + if (arr2.length === 0) return arr1; + + const set1 = new Set(arr1); + const set2 = new Set(arr2); + const newArr = []; - const h1 = Object.create(null); - arr1.forEach(function(e) { - h1[e] = e; - }); - const h2 = Object.create(null); - arr2.forEach(function(e) { - h2[e] = e; + + set1.forEach(element => { + if (!set2.has(element)) newArr.push(element); + }); - Object.keys(h1).forEach(function(e) { - if (!(e in h2)) newArr.push(h1[e]); - }); - Object.keys(h2).forEach(function(e) { - if (!(e in h1)) newArr.push(h2[e]); + set2.forEach(element => { + if (!set1.has(element)) newArr.push(element); + }); + return newArr; + } + ``` diff --git a/curriculum/challenges/arabic/05-back-end-development-and-apis/basic-node-and-express/meet-the-node-console.md b/curriculum/challenges/arabic/05-back-end-development-and-apis/basic-node-and-express/meet-the-node-console.md index 0b0f6f4956a..d29b1e72e18 100644 --- a/curriculum/challenges/arabic/05-back-end-development-and-apis/basic-node-and-express/meet-the-node-console.md +++ b/curriculum/challenges/arabic/05-back-end-development-and-apis/basic-node-and-express/meet-the-node-console.md @@ -20,6 +20,14 @@ Node is just a JavaScript environment. Like client side JavaScript, you can use We recommend to keep the terminal open while working at these challenges. By reading the output in the terminal, you can see any errors that may occur. +The server must be restarted after making changes to its files. + +You can stop the server from the terminal using `Ctrl + C` and start it using Node directly (`node mainEntryFile.js`) or using a run script in the `package.json` file with `npm run`. + +For example, the `"start": "node server.js"` script would be run from the terminal using `npm run start`. + +To implement server auto restarting on file save Node provides the `--watch` flag you can add to your start script `"start": "node --watch server.js"` or you can install an npm package like `nodemon`. We will leave this to you as an exercise. + # --instructions-- Modify the `myApp.js` file to log "Hello World" to the console. diff --git a/curriculum/challenges/arabic/05-back-end-development-and-apis/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md b/curriculum/challenges/arabic/05-back-end-development-and-apis/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md index 31cbe126c5d..12ff3495118 100644 --- a/curriculum/challenges/arabic/05-back-end-development-and-apis/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md +++ b/curriculum/challenges/arabic/05-back-end-development-and-apis/managing-packages-with-npm/how-to-use-package.json-the-core-of-any-node.js-project-or-npm-package.md @@ -14,7 +14,9 @@ dashedName: how-to-use-package-json-the-core-of-any-node-js-project-or-npm-packa - Use our Gitpod starter project to complete these challenges. - استخدم أي منشئ موقع لإكمال المشروع. تحقق انك أضفت جميع الملفات من مستودعنا في GitHub في مشروعك. -إن ملف `package.json` مركز أي مشروع Node.js أو حزمة npm. It stores information about your project, similar to how the `head` section of an HTML document describes the content of a webpage. ويتكون من كائن JSON واحد حيث يتم تخزين المعلومات في أزواج key-value. There are only two required fields; `name` and `version`, but it’s good practice to provide additional information about your project that could be useful to future users or maintainers. +إن ملف `package.json` مركز أي مشروع Node.js أو حزمة npm. It stores information about your project. ويتكون من كائن JSON واحد حيث يتم تخزين المعلومات في أزواج key-value. There are only two required fields; `name` and `version`, but it’s good practice to provide additional information. + +You can create the `package.json` file from the terminal using the `npm init` command. This will run a guided setup. Using `npm init` with the `-y` flag will generate the file without having it ask any questions, `npm init -y`. If you look at the file tree of your project, you will find the `package.json` file on the top level of the tree. هذا هو الملف الذي سوف تحسنه في التحديات القادمة. diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-classes-and-objects-by-building-a-sudoku-solver/65688f737b0ef396bf0c22d6.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-classes-and-objects-by-building-a-sudoku-solver/65688f737b0ef396bf0c22d6.md index 760fc8e59e1..083e9abb00a 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-classes-and-objects-by-building-a-sudoku-solver/65688f737b0ef396bf0c22d6.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-classes-and-objects-by-building-a-sudoku-solver/65688f737b0ef396bf0c22d6.md @@ -27,7 +27,7 @@ puzzle = [ The resulting grid would look like this: - +a board of sudoku Define a method `__str__` within the `Board` class. Also, add the `self` parameter. This method is automatically called when you use the `str()` function on an instance of the class or when you use `print()` with the object. diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/657f425dbab54e11993c80f0.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/657f425dbab54e11993c80f0.md index b1fe8777c15..8d38e50048d 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/657f425dbab54e11993c80f0.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-list-comprehension-by-building-a-case-converter-program/657f425dbab54e11993c80f0.md @@ -20,7 +20,7 @@ You should comment out all the 10 lines of code inside the `convert_to_snake_cas ```js ({ test: () => { - const transformedCode = code.replace(/\r/g, ""); + const transformedCode = code.replace(/\r/g, "").replace(/\n#/g, "\n #"); const convert_to_snake_case = __helpers.python.getDef("\n" + transformedCode, "convert_to_snake_case"); const { function_body } = convert_to_snake_case; diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-regular-expressions-by-building-a-password-generator/657732654845d8e2fb1217e6.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-regular-expressions-by-building-a-password-generator/657732654845d8e2fb1217e6.md index 84c7922fb28..8a2b24836be 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-regular-expressions-by-building-a-password-generator/657732654845d8e2fb1217e6.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-regular-expressions-by-building-a-password-generator/657732654845d8e2fb1217e6.md @@ -9,7 +9,7 @@ dashedName: step-62 `all()` is a built-in Python function that returns `True` if all the elements inside a given iterable evaluate to `True`. Otherwise, it returns `False`. -You can combine the `all()` function with the list comphehension syntax to make your code more concise. +You can combine the `all()` function with the list comprehension syntax to make your code more concise. Modify your `if` condition by passing the list comprehension you created in the previous step to the `all()` function. diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/6554d25dc5ceaa354307a77e.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/6554d25dc5ceaa354307a77e.md index 84f3a8477e1..01efb7bb570 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/6554d25dc5ceaa354307a77e.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/6554d25dc5ceaa354307a77e.md @@ -9,7 +9,7 @@ dashedName: step-69 Encryption and decryption are opposite processes and your function can do both with a couple of tweaks. -Add a third parameter called `direction` to your function definition. Also, comment out the last two lines to avoid errors in the console. +Add a third parameter called `direction` to your function definition. Also, comment out the last two lines of code to avoid errors in the console. # --hints-- diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/655a2a7210094920069b117c.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/655a2a7210094920069b117c.md index 9a4c27f1945..7e9ae9dc9ed 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/655a2a7210094920069b117c.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/655a2a7210094920069b117c.md @@ -36,11 +36,11 @@ Python has the following comparison operators: Less than - ≥ + >= Greater than or equal to - ≤ + <= Less than or equal to diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65560f9380be92226084ef46.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65560f9380be92226084ef46.md index 5e391d108d8..6c2ab7df7ba 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65560f9380be92226084ef46.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65560f9380be92226084ef46.md @@ -11,7 +11,7 @@ In this project, you are going to create a Binary Search Tree (BST). A BST is a This is what a Binary Search Tree looks like: - +a binairy search tree Begin by defining an empty `TreeNode` class. The `TreeNode` class represents a node in a binary search tree. Use the `pass` keyword to fill the class body and avoid an error. diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter.md index 0bba0f81312..c89bf530f0e 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/arithmetic-formatter.md @@ -1,22 +1,13 @@ --- id: 5e44412c903586ffb414c94c title: Arithmetic Formatter -challengeType: 10 +challengeType: 23 forumTopicId: 462359 dashedName: arithmetic-formatter --- # --description-- -You will be working on this project with our Replit starter code. - -- Start by importing the project on Replit. -- Next, you will see a `.replit` window. -- Select `Use run command` and click the `Done` button. - - -# --instructions-- - Students in primary school often arrange arithmetic problems vertically to make them easier to solve. For example, "235 + 52" becomes: ```py @@ -25,7 +16,7 @@ Students in primary school often arrange arithmetic problems vertically to make ----- ``` -Create a function that receives a list of strings that are arithmetic problems and returns the problems arranged vertically and side-by-side. The function should optionally take a second argument. When the second argument is set to `True`, the answers should be displayed. +Finish the `arithmetic_arranger` function that receives a list of strings which are arithmetic problems, and returns the problems arranged vertically and side-by-side. The function should optionally take a second argument. When the second argument is set to `True`, the answers should be displayed. ## Example @@ -62,44 +53,196 @@ Output: The function will return the correct conversion if the supplied problems are properly formatted, otherwise, it will **return** a **string** that describes an error that is meaningful to the user. - - Situations that will return an error: - - If there are **too many problems** supplied to the function. The limit is **five**, anything more will return: `Error: Too many problems.` - - The appropriate operators the function will accept are **addition** and **subtraction**. Multiplication and division will return an error. Other operators not mentioned in this bullet point will not need to be tested. The error returned will be: `Error: Operator must be '+' or '-'.` - - Each number (operand) should only contain digits. Otherwise, the function will return: `Error: Numbers must only contain digits.` - - Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be: `Error: Numbers cannot be more than four digits.` + - If there are **too many problems** supplied to the function. The limit is **five**, anything more will return: `'Error: Too many problems.'` + - The appropriate operators the function will accept are **addition** and **subtraction**. Multiplication and division will return an error. Other operators not mentioned in this bullet point will not need to be tested. The error returned will be: `"Error: Operator must be '+' or '-'."` + - Each number (operand) should only contain digits. Otherwise, the function will return: `'Error: Numbers must only contain digits.'` + - Each operand (aka number on each side of the operator) has a max of four digits in width. Otherwise, the error string returned will be: `'Error: Numbers cannot be more than four digits.'` - If the user supplied the correct format of problems, the conversion you return will follow these rules: - There should be a single space between the operator and the longest of the two operands, the operator will be on the same line as the second operand, both operands will be in the same order as provided (the first will be the top one and the second will be the bottom). - Numbers should be right-aligned. - There should be four spaces between each problem. - There should be dashes at the bottom of each problem. The dashes should run along the entire length of each problem individually. (The example above shows what this should look like.) -## Development - -Write your code in `arithmetic_arranger.py`. For development, you can use `main.py` to test your `arithmetic_arranger()` function. Click the "run" button and `main.py` will run. - -## Testing - -The unit tests for this project are in `test_module.py`. We are running the tests from `test_module.py` in `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button. Alternatively you may run the tests by inputting `pytest` in the console. - -## Submitting - -Copy your project's URL and submit it to freeCodeCamp. - # --hints-- -It should correctly format an arithmetic problem and pass all tests. +`arithmetic_arranger(["3801 - 2", "123 + 49"])` should return `3801 123\n- 2 + 49\n------ -----`. ```js +({ + test: () => { + runPython(` +from unittest import TestCase +TestCase().assertEqual(arithmetic_arranger(["3801 - 2", "123 + 49"]), ' 3801 123\\n- 2 + 49\\n------ -----')`); + } +}) +``` + +`arithmetic_arranger(["1 + 2", "1 - 9380"])` should return `1 1\n+ 2 - 9380\n--- ------`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["1 + 2", "1 - 9380"]), ' 1 1\\n+ 2 - 9380\\n--- ------')`); + } +}) +``` + +`arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"])` should return `3 3801 45 123\n+ 855 - 2 + 43 + 49\n----- ------ ---- -----`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["3 + 855", "3801 - 2", "45 + 43", "123 + 49"]), ' 3 3801 45 123\\n+ 855 - 2 + 43 + 49\\n----- ------ ---- -----')`); + } +}) +``` + +`arithmetic_arranger(["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"])` should return `11 3801 1 123 1\n+ 4 - 2999 + 2 + 49 - 9380\n---- ------ --- ----- ------`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["11 + 4", "3801 - 2999", "1 + 2", "123 + 49", "1 - 9380"]), ' 11 3801 1 123 1\\n+ 4 - 2999 + 2 + 49 - 9380\\n---- ------ --- ----- ------')`); + } +}) +``` + +`arithmetic_arranger(["44 + 815", "909 - 2", "45 + 43", "123 + 49", "888 + 40", "653 + 87"])` should return `'Error: Too many problems.'`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["44 + 815", "909 - 2", "45 + 43", "123 + 49", "888 + 40", "653 + 87"]), 'Error: Too many problems.')`); + } +}) +``` + +`arithmetic_arranger(["3 / 855", "3801 - 2", "45 + 43", "123 + 49"])` should return `"Error: Operator must be '+' or '-'."`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["3 / 855", "3801 - 2", "45 + 43", "123 + 49"]), "Error: Operator must be '+' or '-'.")`); + } +}) +``` + +`arithmetic_arranger(["24 + 85215", "3801 - 2", "45 + 43", "123 + 49"])` should return `'Error: Numbers cannot be more than four digits.'`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["24 + 85215", "3801 - 2", "45 + 43", "123 + 49"]), "Error: Numbers cannot be more than four digits.")`); + } +}) +``` + +`arithmetic_arranger(["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"])` should return `'Error: Numbers must only contain digits.'`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["98 + 3g5", "3801 - 2", "45 + 43", "123 + 49"]), "Error: Numbers must only contain digits.")`); + } +}) +``` + +`arithmetic_arranger(["3 + 855", "988 + 40"], True)` should return `3 988\n+ 855 + 40\n----- -----\n 858 1028`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["3 + 855", "988 + 40"], True), " 3 988\\n+ 855 + 40\\n----- -----\\n 858 1028")`); + } +}) +``` + +`arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49", "988 + 40"], True)` should return `32 1 45 123 988\n- 698 - 3801 + 43 + 49 + 40\n----- ------ ---- ----- -----\n -666 -3800 88 172 1028`. + +```js +({ + test: () => { + runPython(` +from unittest import TestCase + +TestCase().assertEqual(arithmetic_arranger(["32 - 698", "1 - 3801", "45 + 43", "123 + 49", "988 + 40"], True), " 32 1 45 123 988\\n- 698 - 3801 + 43 + 49 + 40\\n----- ------ ---- ----- -----\\n -666 -3800 88 172 1028")`); + } +}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def arithmetic_arranger(problems, show_answers=False): + + return problems + +print(f'\n{arithmetic_arranger(["32 + 698", "3801 - 2", "45 + 43", "123 + 49"])}') ``` # --solutions-- -```js -/** - Backend challenges don't need solutions, - because they would need to be tested against a full working project. - Please check our contributing guidelines to learn more. -*/ +```py +def arithmetic_arranger(problems, result=False): + + lin1 = "" + lin2 = "" + lin3 = "" + lin4 = "" + + if len(problems) > 5: + return 'Error: Too many problems.' + for problem in problems: + [num1, sym, num2] = problem.split() + sign = ['+', '-'] + if sym not in sign: + return ("Error: Operator must be '+' or '-'.") + if len(num1) > 4 or len(num2) > 4: + return ("Error: Numbers cannot be more than four digits.") + if not num1.isnumeric() or not num2.isnumeric(): + return ("Error: Numbers must only contain digits.") + + lin1 += " " + num1 + " " if len(num1) >= len( + num2) else " " * (len(num2) + 2 - len(num1)) + num1 + " " + lin2 += sym + " " + num2 + " " if len(num2) >= len( + num1) else sym + " " * (len(num1) - len(num2) + 1) + num2 + " " + nmax = (len(num1) + 2) if len(num1) >= len(num2) else (len(num2) + 2) + lin3 += "-" * nmax + " " + op = int(num1) + int(num2) if sym == "+" else int(num1) - int(num2) + lin4 += (" " * (nmax - len(str(op)))) + str(op) + " " + + arranged_problems = lin1.rstrip() + "\n" + lin2.rstrip( + ) + "\n" + lin3.rstrip() + if result: + arranged_problems += "\n" + lin4.rstrip() + + return arranged_problems ``` diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/budget-app.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/budget-app.md index a233fad342e..fa12826889c 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/budget-app.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/budget-app.md @@ -1,23 +1,14 @@ --- id: 5e44413e903586ffb414c94e title: Budget App -challengeType: 10 +challengeType: 23 forumTopicId: 462361 dashedName: budget-app --- # --description-- -You will be working on this project with our Replit starter code. - -- Start by importing the project on Replit. -- Next, you will see a `.replit` window. -- Select `Use run command` and click the `Done` button. - - -# --instructions-- - -Complete the `Category` class in `budget.py`. It should be able to instantiate objects based on different budget categories like *food*, *clothing*, and *entertainment*. When objects are created, they are passed in the name of the category. The class should have an instance variable called `ledger` that is a list. The class should also contain the following methods: +Complete the `Category` class. It should be able to instantiate objects based on different budget categories like *food*, *clothing*, and *entertainment*. When objects are created, they are passed in the name of the category. The class should have an instance variable called `ledger` that is a list. The class should also contain the following methods: - A `deposit` method that accepts an amount and description. If no description is given, it should default to an empty string. يجب أن تضيف الوظيفة كائنً (object) إلى ledgerList بهذا الشكل `{"amount": amount, "description": description}`. - A `withdraw` method that is similar to the `deposit` method, but the amount passed in should be stored in the ledger as a negative number. If there are not enough funds, nothing should be added to the ledger. This method should return `True` if the withdrawal took place, and `False` otherwise. @@ -31,7 +22,19 @@ When the budget object is printed it should display: - A list of the items in the ledger. Each line should show the description and amount. The first 23 characters of the description should be displayed, then the amount. The amount should be right aligned, contain two decimal places, and display a maximum of 7 characters. - A line displaying the category total. -Here is an example of the output: +Here is an example usage: + +```py +food = Category("Food") +food.deposit(1000, "deposit") +food.withdraw(10.15, "groceries") +food.withdraw(15.89, "restaurant and more food for dessert") +clothing = Category("Clothing") +food.transfer(50, clothing) +print(food) +``` + +And here is an example of the output: ```bash *************Food************* @@ -74,34 +77,811 @@ Percentage spent by category g ``` -The unit tests for this project are in `test_module.py`. - -## Development - -Write your code in `budget.py`. For development, you can use `main.py` to test your `Category` class. Click the "run" button and `main.py` will run. - -## Testing - -We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button. - -## Submitting - -Copy your project's URL and submit it to freeCodeCamp. - # --hints-- -It should create a Category class and pass all tests. +The `deposit` method should create a specific object in the ledger instance variable. ```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_deposit(self): + self.food.deposit(900, "deposit") + actual = self.food.ledger[0] + expected = {"amount": 900, "description": "deposit"} + self.assertEqual(actual, expected, 'Expected "deposit" method to create a specific object in the ledger instance variable.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling the `deposit` method with no description should create a blank description. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_deposit_no_description(self): + self.food.deposit(45.56) + actual = self.food.ledger[0] + expected = {"amount": 45.56, "description": ""} + self.assertEqual(actual, expected, 'Expected calling "deposit" method with no description to create a blank description.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `withdraw` method should create a specific object in the `ledger` instance variable. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_withdraw(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + actual = self.food.ledger[1] + expected = {"amount": -45.67, "description": "milk, cereal, eggs, bacon, bread"} + self.assertEqual(actual, expected, 'Expected "withdraw" method to create a specific object in the ledger instance variable.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling the `withdraw` method with no description should create a blank description. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_withdraw_no_description(self): + self.food.deposit(900, "deposit") + good_withdraw = self.food.withdraw(45.67) + actual = self.food.ledger[1] + expected = {"amount": -45.67, "description": ""} + self.assertEqual(actual, expected, 'Expected "withdraw" method with no description to create a blank description.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `withdraw` method should return `True` if the withdrawal took place. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_withdraw_no_description(self): + self.food.deposit(900, "deposit") + good_withdraw = self.food.withdraw(45.67) + self.assertEqual(good_withdraw, True, 'Expected "withdraw" method to return "True".') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `food.deposit(900, "deposit")` and `food.withdraw(45.67, "milk, cereal, eggs, bacon, bread")` should return a balance of `854.33`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_get_balance(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + actual = self.food.get_balance() + expected = 854.33 + self.assertEqual(actual, expected, 'Expected balance to be 854.33') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling the `transfer` method on a category object should create a specific ledger item in that category object. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_transfer(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + transfer_amount = 20 + good_transfer = self.food.transfer(transfer_amount, self.entertainment) + actual = self.food.ledger[2] + expected = {"amount": -transfer_amount, "description": "Transfer to Entertainment"} + self.assertEqual(actual, expected, 'Expected "transfer" method to create a specific ledger item in food object.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `transfer` method should return `True` if the transfer took place. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_transfer(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + transfer_amount = 20 + good_transfer = self.food.transfer(transfer_amount, self.entertainment) + self.assertEqual(good_transfer, True, 'Expected "transfer" method to return "True".') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `transfer` on a category object should reduce the balance in the category object. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_transfer(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + transfer_amount = 20 + food_balance_before = self.food.get_balance() + good_transfer = self.food.transfer(transfer_amount, self.entertainment) + food_balance_after = self.food.get_balance() + self.assertEqual(food_balance_before - food_balance_after, transfer_amount, 'Expected "transfer" method to reduce balance in food object.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `transfer` method should increase the balance of the category object passed as its argument. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_transfer(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + transfer_amount = 20 + entertainment_balance_before = self.entertainment.get_balance() + good_transfer = self.food.transfer(transfer_amount, self.entertainment) + entertainment_balance_after = self.entertainment.get_balance() + self.assertEqual(entertainment_balance_after - entertainment_balance_before, transfer_amount, 'Expected "transfer" method to increase balance in entertainment object.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `transfer` method should create a specific ledger item in the category object passed as its argument. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_transfer(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + transfer_amount = 20 + good_transfer = self.food.transfer(transfer_amount, self.entertainment) + actual = self.entertainment.ledger[0] + expected = {"amount": transfer_amount, "description": "Transfer from Food"} + self.assertEqual(actual, expected, 'Expected "transfer" method to create a specific ledger item in entertainment object.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `check_funds` method should return `False` if the amount passed to the method is greater than the category balance. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_check_funds(self): + self.food.deposit(10, "deposit") + actual = self.food.check_funds(20) + expected = False + self.assertEqual(actual, expected, 'Expected "check_funds" method to be False') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `check_funds` method should return `True` if the amount passed to the method is not greater than the category balance. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_check_funds(self): + self.food.deposit(10, "deposit") + actual = self.food.check_funds(10) + expected = True + self.assertEqual(actual, expected, 'Expected "check_funds" method to be True') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `withdraw` method should return `False` if the withdrawal didn't take place. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + + def test_withdraw_no_funds(self): + self.food.deposit(100, "deposit") + good_withdraw = self.food.withdraw(100.10) + self.assertEqual(good_withdraw, False, 'Expected "withdraw" method to return "False".') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `transfer` method should return `False` if the transfer didn't take place. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_transfer_no_funds(self): + self.food.deposit(100, "deposit") + good_transfer = self.food.transfer(200, self.entertainment) + self.assertEqual(good_transfer, False, 'Expected "transfer" method to return "False".') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Printing a `Category` instance should give a different string representation of the object. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + + def test_to_string(self): + self.food.deposit(900, "deposit") + self.food.withdraw(45.67, "milk, cereal, eggs, bacon, bread") + self.food.transfer(20, self.entertainment) + actual = str(self.food) + expected = "*************Food*************\\ndeposit 900.00\\nmilk, cereal, eggs, bac -45.67\\nTransfer to Entertainme -20.00\\nTotal: 834.33" + self.assertEqual(actual, expected, 'Expected different string representation of object.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +` + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`create_spend_chart` should print a different chart representation. Check that all spacing is exact. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/budget.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import budget +from importlib import reload + +reload(budget) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.food = budget.Category("Food") + self.entertainment = budget.Category("Entertainment") + self.business = budget.Category("Business") + + def test_create_spend_chart(self): + self.food.deposit(900, "deposit") + self.entertainment.deposit(900, "deposit") + self.business.deposit(900, "deposit") + self.food.withdraw(105.55) + self.entertainment.withdraw(33.40) + self.business.withdraw(10.99) + actual = budget.create_spend_chart([self.business, self.food, self.entertainment]) + expected = "Percentage spent by category\\n100| \\n 90| \\n 80| \\n 70| o \\n 60| o \\n 50| o \\n 40| o \\n 30| o \\n 20| o o \\n 10| o o \\n 0| o o o \\n ----------\\n B F E \\n u o n \\n s o t \\n i d e \\n n r \\n e t \\n s a \\n s i \\n n \\n m \\n e \\n n \\n t " + self.assertEqual(actual, expected, 'Expected different chart representation. Check that all spacing is exact.') +`); + + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +# --seed-- + +## --seed-contents-- + +```py +class Category: + pass + +def create_spend_chart(categories): + pass ``` # --solutions-- -```js -/** - Backend challenges don't need solutions, - because they would need to be tested against a full working project. - Please check our contributing guidelines to learn more. -*/ +```py +class Category: + + def __init__(self, name): + self.name = name + self.ledger = [] + self.balance = 0 + self.spent = 0 + + def __str__(self): + first_line = f'{self.name.center(30, "*")}\n' + lines = '' + total = f'Total: {format(self.balance, ".2f")}' + + for n in range(len(self.ledger)): + descr = self.ledger[n]["description"][:23] + am = format(float(self.ledger[n]["amount"]), ".2f")[:7] + lines = lines + f'{descr:<23}{am:>7}\n' + + return f'{first_line}{lines}{total}' + + def deposit(self, amount, description=''): + self.ledger.append({ + 'amount': float(amount), + 'description': description + }) + self.balance = self.balance + float(amount) + + def withdraw(self, amount, description=''): + if self.check_funds(amount): + self.ledger.append({ + 'amount': -float(amount), + 'description': description + }) + self.balance = self.balance - float(amount) + self.spent = self.spent + float(amount) + return True + else: + return False + + def get_balance(self): + return self.balance + + def transfer(self, amount, category): + if self.check_funds(amount): + # withdraw + self.ledger.append({ + 'amount': -float(amount), + 'description': f'Transfer to {category.name}' + }) + self.balance = self.balance - float(amount) + # deposit + category.deposit(amount, f'Transfer from {self.name}') + + return True + else: + return False + + def check_funds(self, amount): + if float(amount) > self.balance: + return False + else: + return True + + +def create_spend_chart(categories): + total_expenses = 0 + obj = {} + col1 = [] + str = [] + final_str = 'Percentage spent by category\n' + label_max_length = 0 + label_strings = [] + + for category in categories: + total_expenses = total_expenses + category.spent + obj[category.name] = {'expenses': category.spent} + obj[category.name]['label'] = list(category.name) + if len(obj[category.name]['label']) > label_max_length: + label_max_length = len(obj[category.name]['label']) + + for category in categories: + obj[category.name]['percent'] = ( + (category.spent / total_expenses * 100) // 10) * 10 + obj[category.name]['column'] = [] + for i in range(0, 110, 10): + if obj[category.name]['percent'] >= i: + obj[category.name]['column'].insert(0, 'o') + else: + obj[category.name]['column'].insert(0, ' ') + + for i in range(0, 110, 10): + col1.insert(0, i) + + for i in range(11): + str.append("") + for key in obj: + str[i] += (f'{obj[key]["column"][i]} ') + final_str += f'{col1[i]:>3}| {str[i]}\n' + final_str += f' {"-"*(1+3*len(obj))}\n ' + + for i in range(label_max_length): + label_strings.append(' ') + for k in obj: + if len(obj[k]['label']) < label_max_length: + obj[k]['label'].extend( + f'{" "*(label_max_length-len(obj[k]["label"]))}') + + label_strings[i] += f'{obj[k]["label"][i]} ' + if i < label_max_length - 1: + label_strings[i] += '\n ' + final_str += label_strings[i] + + print(final_str) + return (final_str) + ``` diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator.md index 97e39369a48..c0b8b6d6a64 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/polygon-area-calculator.md @@ -1,23 +1,14 @@ --- id: 5e444147903586ffb414c94f title: Polygon Area Calculator -challengeType: 10 +challengeType: 23 forumTopicId: 462363 dashedName: polygon-area-calculator --- # --description-- -You will be working on this project with our Replit starter code. - -- Start by importing the project on Replit. -- Next, you will see a `.replit` window. -- Select `Use run command` and click the `Done` button. - - -# --instructions-- - -In this project you will use object oriented programming to create a Rectangle class and a Square class. The Square class should be a subclass of Rectangle and inherit methods and attributes. +In this project you will use object oriented programming to create a `Rectangle` class and a `Square` class. The `Square` class should be a subclass of `Rectangle`, and inherit its methods and attributes. ## Rectangle class @@ -31,27 +22,27 @@ When a Rectangle object is created, it should be initialized with `width` and `h - `get_picture`: Returns a string that represents the shape using lines of "\*". The number of lines should be equal to the height and the number of "\*" in each line should be equal to the width. There should be a new line (`\n`) at the end of each line. If the width or height is larger than 50, this should return the string: "Too big for picture.". - `get_amount_inside`: Takes another shape (square or rectangle) as an argument. Returns the number of times the passed in shape could fit inside the shape (with no rotations). For instance, a rectangle with a width of 4 and a height of 8 could fit in two squares with sides of 4. -Additionally, if an instance of a Rectangle is represented as a string, it should look like: `Rectangle(width=5, height=10)` +Additionally, if an instance of a `Rectangle` is represented as a string, it should look like: `Rectangle(width=5, height=10)` ## Square class -The Square class should be a subclass of Rectangle. When a Square object is created, a single side length is passed in. The `__init__` method should store the side length in both the `width` and `height` attributes from the Rectangle class. +The `Square` class should be a subclass of `Rectangle`. When a `Square` object is created, a single side length is passed in. The `__init__` method should store the side length in both the `width` and `height` attributes from the `Rectangle` class. -The Square class should be able to access the Rectangle class methods but should also contain a `set_side` method. If an instance of a Square is represented as a string, it should look like: `Square(side=9)` +The `Square` class should be able to access the `Rectangle` class methods but should also contain a `set_side` method. If an instance of a `Square` is represented as a string, it should look like: `Square(side=9)` -Additionally, the `set_width` and `set_height` methods on the Square class should set both the width and height. +Additionally, the `set_width` and `set_height` methods on the `Square` class should set both the width and height. ## Usage example ```py -rect = shape_calculator.Rectangle(10, 5) +rect = Rectangle(10, 5) print(rect.get_area()) rect.set_height(3) print(rect.get_perimeter()) print(rect) print(rect.get_picture()) -sq = shape_calculator.Square(9) +sq = Square(9) print(sq.get_area()) sq.set_side(4) print(sq.get_diagonal()) @@ -84,34 +75,795 @@ Square(side=4) 8 ``` -The unit tests for this project are in `test_module.py`. - -## Development - -Write your code in `shape_calculator.py`. For development, you can use `main.py` to test your `shape_calculator()` function. Click the "run" button and `main.py` will run. - -## Testing - -We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button. - -## Submitting - -Copy your project's URL and submit it to freeCodeCamp. - # --hints-- -It should create a Rectangle class and Square class and pass all tests. +The `Square` class should be a subclass of the `Rectangle` class. ```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def test_subclass(self): + actual = issubclass(shape_calculator.Square, shape_calculator.Rectangle) + expected = True + self.assertEqual(actual, expected, 'Expected Square class to be a subclass of the Rectangle class.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `Square` class should be a distinct class from the `Rectangle` class. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + + def test_distinct_classes(self): + actual = shape_calculator.Square is not shape_calculator.Rectangle + expected = True + self.assertEqual(actual, expected, 'Expected Square class to be a distinct class from the Rectangle class.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +A square object should be an instance of the `Square` class and the `Rectangle` class. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_square_is_square_and_rectangle(self): + actual = isinstance(self.sq, shape_calculator.Square) and isinstance(self.sq, shape_calculator.Rectangle) + expected = True + self.assertEqual(actual, expected, 'Expected square object to be an instance of the Square class and the Rectangle class.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The string representation of `Rectangle(3, 6)` should be `Rectangle(width=3, height=6)`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_rectangle_string(self): + actual = str(self.rect) + expected = "Rectangle(width=3, height=6)" + self.assertEqual(actual, expected, 'Expected string representation of rectangle to be "Rectangle(width=3, height=6)"') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The string representation of `Square(5)` should be `Square(side=5)`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_square_string(self): + actual = str(self.sq) + expected = "Square(side=5)" + self.assertEqual(actual, expected, 'Expected string representation of square to be "Square(side=5)"') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Rectangle(3, 6).get_area()` should return `18`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_area(self): + actual = self.rect.get_area() + expected = 18 + self.assertEqual(actual, expected, 'Expected area of rectangle to be 18') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Square(5).get_area()` should return `25`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_area(self): + actual = self.sq.get_area() + expected = 25 + self.assertEqual(actual, expected, 'Expected area of square to be 25') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Rectangle(3, 6).get_perimeter()` should return `18`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_perimeter(self): + actual = self.rect.get_perimeter() + expected = 18 + self.assertEqual(actual, expected, 'Expected perimeter of rectangle to be 18') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Square(5).get_perimeter()` should return `20`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_perimeter(self): + actual = self.sq.get_perimeter() + expected = 20 + self.assertEqual(actual, expected, 'Expected perimeter of square to be 20') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Rectangle(3, 6).get_diagonal()` should return `6.708203932499369`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_diagonal(self): + actual = self.rect.get_diagonal() + expected = 6.708203932499369 + self.assertEqual(actual, expected, 'Expected diagonal of rectangle to be 6.708203932499369') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Square(5).get_diagonal()` should return `7.0710678118654755`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_diagonal(self): + actual = self.sq.get_diagonal() + expected = 7.0710678118654755 + self.assertEqual(actual, expected, 'Expected diagonal of square to be 7.0710678118654755') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +An instance of the `Rectangle` class should have a different string representation after setting new values. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_set_attributes(self): + self.rect.set_width(7) + self.rect.set_height(8) + actual = str(self.rect) + expected = "Rectangle(width=7, height=8)" + self.assertEqual(actual, expected, 'Expected string representation of rectangle after setting new values to be "Rectangle(width=7, height=8)"') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +An instance of the `Square` class should have a different string representation after setting new values by using `.set_side()`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_set_attributes(self): + self.sq.set_side(2) + actual = str(self.sq) + expected = "Square(side=2)" + self.assertEqual(actual, expected, 'Expected string representation of square after setting new values to be "Square(side=2)"') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +An instance of the `Square` class should have a different string representation after setting new values by using `.set_width()` or `set_height()`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_set_attributes(self): + self.sq.set_height(2) + actual = str(self.sq) + expected = "Square(side=2)" + self.assertEqual(actual, expected, 'Expected string representation of square after setting new values to be "Square(side=2)"') + self.sq.set_width(4) + actual = str(self.sq) + expected = "Square(side=4)" + self.assertEqual(actual, expected, 'Expected string representation of square after setting width to be "Square(side=4)"') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `.get_picture()` method should return a different string representation of a `Rectangle` instance. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_rectangle_picture(self): + self.rect.set_width(7) + self.rect.set_height(3) + actual = self.rect.get_picture() + expected = "*******\\n*******\\n*******\\n" + self.assertEqual(actual, expected, 'Expected rectangle picture to be different.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `.get_picture()` method should return a different string representation of a `Square` instance. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.sq = shape_calculator.Square(5) + + def test_square_picture(self): + self.sq.set_side(2) + actual = self.sq.get_picture() + expected = "**\\n**\\n" + self.assertEqual(actual, expected, 'Expected square picture to be different.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +The `.get_picture()` method should return the string `Too big for picture.` if the `width` or `height` attributes are larger than `50`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_big_picture(self): + self.rect.set_width(51) + self.rect.set_height(3) + actual = self.rect.get_picture() + expected = "Too big for picture." + self.assertEqual(actual, expected, 'Expected message: "Too big for picture."') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Rectangle(15,10).get_amount_inside(Square(5))` should return `6`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + self.sq = shape_calculator.Square(5) + + def test_get_amount_inside(self): + self.rect.set_height(10) + self.rect.set_width(15) + actual = self.rect.get_amount_inside(self.sq) + expected = 6 + self.assertEqual(actual, expected, 'Expected "get_amount_inside" to return 6.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Rectangle(4,8).get_amount_inside(Rectangle(3, 6))` should return `1`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_get_amount_inside_two_rectangles(self): + rect2 = shape_calculator.Rectangle(4, 8) + actual = rect2.get_amount_inside(self.rect) + expected = 1 + self.assertEqual(actual, expected, 'Expected "get_amount_inside" to return 1.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +`Rectangle(2,3).get_amount_inside(Rectangle(3, 6))` should return `0`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/shape_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py',` +import unittest +import shape_calculator +from importlib import reload +reload(shape_calculator) +class UnitTests(unittest.TestCase): + maxDiff = None + def setUp(self): + self.rect = shape_calculator.Rectangle(3, 6) + + def test_get_amount_inside_none(self): + rect2 = shape_calculator.Rectangle(2, 3) + actual = rect2.get_amount_inside(self.rect) + expected = 0 + self.assertEqual(actual, expected, 'Expected "get_amount_inside" to return 0.') +`); + const testCode = ` +from unittest import main +from importlib import reload +import test_module +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +# --seed-- + +## --seed-contents-- + +```py +class Rectangle: + pass + +class Square: + pass ``` # --solutions-- -```js -/** - Backend challenges don't need solutions, - because they would need to be tested against a full working project. - Please check our contributing guidelines to learn more. -*/ +```py +class Rectangle: + def __init__(self, width, height): + self.width = width + self.height = height + + def __str__(self): + return f'Rectangle(width={self.width}, height={self.height})' + + def set_width(self, width): + self.width = width + + def set_height(self, height): + self.height = height + + def get_area(self): + area = self.width * self.height + return area + + def get_perimeter(self): + perimeter = self.width * 2 + self.height * 2 + return perimeter + + def get_diagonal(self): + diagonal = (self.width ** 2 + self.height ** 2) ** 0.5 + return diagonal + + def get_picture(self): + if self.width < 50 and self.height < 50: + picture = f'{"*"*self.width}\n'*self.height + return picture + else: + return 'Too big for picture.' + + def get_amount_inside(self, polygon): + h_number = self.height // polygon.height + w_number = self.width // polygon.width + repetition = h_number * w_number + return repetition + + +class Square(Rectangle): + def __init__(self, side): + self.width = side + self.height = side + + def __str__(self): + return f'Square(side={self.width})' + + def set_width(self, side): + self.width = side + self.height = side + + def set_height(self, side): + self.height = side + self.width = side + + def set_side(self,side): + self.width = side + self.height = side + ``` diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/probability-calculator.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/probability-calculator.md index aa3714d589b..67ac4c0e173 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/probability-calculator.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/probability-calculator.md @@ -1,27 +1,18 @@ --- id: 5e44414f903586ffb414c950 title: Probability Calculator -challengeType: 10 +challengeType: 23 forumTopicId: 462364 dashedName: probability-calculator --- # --description-- -You will be working on this project with our Replit starter code. - -- Start by importing the project on Replit. -- Next, you will see a `.replit` window. -- Select `Use run command` and click the `Done` button. - - -# --instructions-- - Suppose there is a hat containing 5 blue balls, 4 red balls, and 2 green balls. What is the probability that a random draw of 4 balls will contain at least 1 red ball and 2 green balls? While it would be possible to calculate the probability using advanced mathematics, an easier way is to write a program to perform a large number of experiments to estimate an approximate probability. For this project, you will write a program to determine the approximate probability of drawing certain balls randomly from a hat. -First, create a `Hat` class in `prob_calculator.py`. The class should take a variable number of arguments that specify the number of balls of each color that are in the hat. For example, a class object could be created in any of these ways: +First, create a `Hat` class in `main.py`. The class should take a variable number of arguments that specify the number of balls of each color that are in the hat. For example, a class object could be created in any of these ways: ```py hat1 = Hat(yellow=3, blue=2, green=6) @@ -33,7 +24,7 @@ A hat will always be created with at least one ball. The arguments passed into t The `Hat` class should have a `draw` method that accepts an argument indicating the number of balls to draw from the hat. This method should remove balls at random from `contents` and return those balls as a list of strings. The balls should not go back into the hat during the draw, similar to an urn experiment without replacement. If the number of balls to draw exceeds the available quantity, return all the balls. -Next, create an `experiment` function in `prob_calculator.py` (not inside the `Hat` class). This function should accept the following arguments: +Next, create an `experiment` function in `main.py` (not inside the `Hat` class). This function should accept the following arguments: - `hat`: A hat object containing balls that should be copied inside the function. - `expected_balls`: An object indicating the exact group of balls to attempt to draw from the hat for the experiment. For example, to determine the probability of drawing 2 blue balls and 1 red ball from the hat, set `expected_balls` to `{"blue":2, "red":1}`. @@ -54,38 +45,215 @@ probability = experiment(hat=hat, num_experiments=2000) ``` +The output would be something like this: + +```bash +>>> 0.356 +``` + Since this is based on random draws, the probability will be slightly different each time the code is run. -*Hint: Consider using the modules that are already imported at the top of `prob_calculator.py`. Do not initialize random seed within `prob_calculator.py`.* +_Hint: Consider using the modules that are already imported at the top. Do not initialize random seed within the file._ -## Development - -Write your code in `prob_calculator.py`. For development, you can use `main.py` to test your code. Click the "run" button and `main.py` will run. - -The boilerplate includes `import` statements for the `copy` and `random` modules. Consider using those in your project. - -## Testing - -The unit tests for this project are in `test_module.py`. We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button. - -## Submitting - -Copy your project's URL and submit it to freeCodeCamp. # --hints-- -It should correctly calculate probabilities and pass all tests. +Creation of `hat` object should add correct contents. ```js +({ + test: () => { + pyodide.FS.writeFile("/home/pyodide/probability_calculator.py", code); + pyodide.FS.writeFile( + "/home/pyodide/test_module.py", + ` +import unittest +import probability_calculator +from importlib import reload +reload(probability_calculator) + +probability_calculator.random.seed(95) +class UnitTests(unittest.TestCase): + maxDiff = None + def test_hat_class_contents(self): + hat = probability_calculator.Hat(red=3,blue=2) + actual = hat.contents + expected = ["red","red","red","blue","blue"] + self.assertEqual(actual, expected, 'Expected creation of hat object to add correct contents.') + ` + ); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + }, +}); +``` + +The `draw` method in `hat` class should reduce number of items in contents. + + +```js +({ + test: () => { + pyodide.FS.writeFile("/home/pyodide/probability_calculator.py", code); + pyodide.FS.writeFile( + "/home/pyodide/test_module.py", + ` +import unittest +import probability_calculator +from importlib import reload + +reload(probability_calculator) + +probability_calculator.random.seed(95) +def test_hat_draw(self): + hat = probability_calculator.Hat(red=5,blue=2) + actual = hat.draw(2) + expected = ['blue', 'red'] + self.assertEqual(actual, expected, 'Expected hat draw to return two random items from hat contents.') + actual = len(hat.contents) + expected = 5 + self.assertEqual(actual, expected, 'Expected hat draw to reduce number of items in contents.') + ` + ); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + }, +}); +``` + +The `experiment` method should return a different probability. + + +```js +({ + test: () => { + pyodide.FS.writeFile("/home/pyodide/probability_calculator.py", code); + pyodide.FS.writeFile( + "/home/pyodide/test_module.py", + ` +import unittest +import probability_calculator +from importlib import reload + +reload(probability_calculator) + +probability_calculator.random.seed(95) +class UnitTests(unittest.TestCase): + maxDiff = None + def test_prob_experiment(self): + hat = probability_calculator.Hat(blue=3,red=2,green=6) + probability = probability_calculator.experiment(hat=hat, expected_balls={"blue":2,"green":1}, num_balls_drawn=4, num_experiments=1000) + actual = probability + expected = 0.272 + self.assertAlmostEqual(actual, expected, delta = 0.01, msg = 'Expected experiment method to return a different probability.') + hat = probability_calculator.Hat(yellow=5,red=1,green=3,blue=9,test=1) + probability = probability_calculator.experiment(hat=hat, expected_balls={"yellow":2,"blue":3,"test":1}, num_balls_drawn=20, num_experiments=100) + actual = probability + expected = 1.0 + self.assertAlmostEqual(actual, expected, delta = 0.01, msg = 'Expected experiment method to return a different probability.') + ` + ); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + }, +}); +``` + +# --seed-- + +## --seed-contents-- + +```py +import copy +import random + +class Hat: + pass + +def experiment(hat, expected_balls, num_balls_drawn, num_experiments): + pass ``` # --solutions-- -```js -/** - Backend challenges don't need solutions, - because they would need to be tested against a full working project. - Please check our contributing guidelines to learn more. -*/ +```py +import copy +import random + +class Hat: + def __init__(self, **hat): + self.hat = hat + contents = [] + for i in hat: + for j in range(hat[i]): + contents.append(i) + self.contents = contents + + + def draw(self, number): + drawn = [] + if number >= len(self.contents): + return self.contents + else: + for i in range(number): + drawn.append( + self.contents.pop(random.randrange(len(self.contents))) + ) + return drawn + +def experiment(hat, expected_balls, num_balls_drawn, num_experiments): + + expected_balls_list = [] + drawn_list = [] + success = 0 + for i in expected_balls: + for j in range(expected_balls[i]): + expected_balls_list.append(i) + for j in range(num_experiments): + hat_copy = copy.deepcopy(hat) + drawn_list.append(hat_copy.draw(num_balls_drawn)) + exp_ball_list_copy = expected_balls_list[:] + for k in range(len(drawn_list[j])): + try: + ind = exp_ball_list_copy.index(drawn_list[j][k]) + exp_ball_list_copy.pop(ind) + except: + continue + if len(exp_ball_list_copy) == 0: + success += 1 + + + + + probability = success/num_experiments + + return probability ``` diff --git a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator.md b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator.md index 085df00550a..b845a8b4a00 100644 --- a/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator.md +++ b/curriculum/challenges/arabic/07-scientific-computing-with-python/scientific-computing-with-python-projects/time-calculator.md @@ -1,21 +1,13 @@ --- id: 5e444136903586ffb414c94d title: Time Calculator -challengeType: 10 +challengeType: 23 forumTopicId: 462360 dashedName: time-calculator --- # --description-- -You will be working on this project with our Replit starter code. - -- Start by importing the project on Replit. -- Next, you will see a `.replit` window. -- Select `Use run command` and click the `Done` button. - -# --instructions-- - Write a function named `add_time` that takes in two required parameters and one optional parameter: - a start time in the 12-hour clock format (ending in AM or PM) @@ -31,53 +23,560 @@ If the function is given the optional starting day of the week parameter, then t Below are some examples of different cases the function should handle. Pay close attention to the spacing and punctuation of the results. ```py -add_time("3:00 PM", "3:10") +add_time('3:00 PM', '3:10') # Returns: 6:10 PM -add_time("11:30 AM", "2:32", "Monday") +add_time('11:30 AM', '2:32', 'Monday') # Returns: 2:02 PM, Monday -add_time("11:43 AM", "00:20") +add_time('11:43 AM', '00:20') # Returns: 12:03 PM -add_time("10:10 PM", "3:30") +add_time('10:10 PM', '3:30') # Returns: 1:40 AM (next day) -add_time("11:43 PM", "24:20", "tueSday") +add_time('11:43 PM', '24:20', 'tueSday') # Returns: 12:03 AM, Thursday (2 days later) -add_time("6:30 PM", "205:12") +add_time('6:30 PM', '205:12') # Returns: 7:42 AM (9 days later) ``` Do not import any Python libraries. Assume that the start times are valid times. The minutes in the duration time will be a whole number less than 60, but the hour can be any whole number. -## Development - -Write your code in `time_calculator.py`. For development, you can use `main.py` to test your `time_calculator()` function. Click the "run" button and `main.py` will run. - -## Testing - -The unit tests for this project are in `test_module.py`. We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button. - -## Submitting - -Copy your project's URL and submit it to freeCodeCamp. - # --hints-- - -It should correctly add times and pass all tests. +Calling `add_time('3:30 PM', '2:12')` should return `'5:42 PM'`. ```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +import time_calculator +from importlib import reload +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_same_period(self): + actual = time_calculator.add_time("3:30 PM", "2:12") + expected = "5:42 PM" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "3:30 PM", "2:12" to return "5:42 PM"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `add_time('11:55 AM', '3:12')` should return `'3:07 PM'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_different_period(self): + actual = time_calculator.add_time("11:55 AM", "3:12") + expected = "3:07 PM" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:55 AM", "3:12" to return "3:07 PM"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Expected time to end with `'(next day)'` when it is the next day. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_next_day(self): + actual = time_calculator.add_time("9:15 PM", "5:30") + expected = "2:45 AM (next day)" + self.assertEqual(actual, expected, 'Expected time to end with "(next day)" when it is the next day.') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Expected period to change from `AM` to `PM` at `12:00`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_period_change_at_twelve(self): + actual = time_calculator.add_time("11:40 AM", "0:25") + expected = "12:05 PM" + self.assertEqual(actual, expected, 'Expected period to change from AM to PM at 12:00') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + + +Calling `add_time('2:59 AM', '24:00')` should return `'2:59 AM (next day)'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_twenty_four(self): + actual = time_calculator.add_time("2:59 AM", "24:00") + expected = "2:59 AM (next day)" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00" to return "2:59 AM (next day)"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `add_time('11:59 PM', '24:05')` should return `'12:04 AM (2 days later)'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_two_days_later(self): + actual = time_calculator.add_time("11:59 PM", "24:05") + expected = "12:04 AM (2 days later)" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:59 PM", "24:05" to return "12:04 AM (2 days later)"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `add_time('8:16 PM', '466:02')` should return `'6:18 AM (20 days later)'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_high_duration(self): + actual = time_calculator.add_time("8:16 PM", "466:02") + expected = "6:18 AM (20 days later)" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "8:16 PM", "466:02" to return "6:18 AM (20 days later)"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Expected adding `0:00` to return the initial time. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_no_change(self): + actual = time_calculator.add_time("5:01 AM", "0:00") + expected = "5:01 AM" + self.assertEqual(actual, expected, 'Expected adding 0:00 to return initial time.') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + + +Calling `add_time('3:30 PM', '2:12', 'Monday')`should return `'5:42 PM, Monday'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_same_period_with_day(self): + actual = time_calculator.add_time("3:30 PM", "2:12", "Monday") + expected = "5:42 PM, Monday" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "3:30 PM", "2:12", "Monday" to return "5:42 PM, Monday"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + + +Calling `add_time('2:59 AM', '24:00', 'saturDay')` should return `'2:59 AM, Sunday (next day)'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_twenty_four_with_day(self): + actual = time_calculator.add_time("2:59 AM", "24:00", "saturDay") + expected = "2:59 AM, Sunday (next day)" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "2:59 AM", "24:00", "saturDay" to return "2:59 AM, Sunday (next day)"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `add_time('11:59 PM', '24:05', 'Wednesday')` should return `'12:04 AM, Friday (2 days later)'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_two_days_later_with_day(self): + actual = time_calculator.add_time("11:59 PM", "24:05", "Wednesday") + expected = "12:04 AM, Friday (2 days later)" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "11:59 PM", "24:05", "Wednesday" to return "12:04 AM, Friday (2 days later)"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +Calling `add_time('8:16 PM', '466:02', 'tuesday')`should return `'6:18 AM, Monday (20 days later)'`. + +```js +({ + test: () => { + pyodide.FS.writeFile('/home/pyodide/time_calculator.py', code); + pyodide.FS.writeFile('/home/pyodide/test_module.py', ` +import unittest +time_calculator +from importlib import reload + +reload(time_calculator) + + +class UnitTests(unittest.TestCase): + maxDiff = None + def test_high_duration_with_day(self): + actual = time_calculator.add_time("8:16 PM", "466:02", "tuesday") + expected = "6:18 AM, Monday (20 days later)" + self.assertEqual(actual, expected, 'Expected calling "add_time()" with "8:16 PM", "466:02", "tuesday" to return "6:18 AM, Monday (20 days later)"') + `); + const testCode = ` +from unittest import main +import test_module +from importlib import reload + +reload(test_module) +t = main(module='test_module', exit=False) +t.result.wasSuccessful() +`; + const out = __pyodide.runPython(testCode); + assert(out); + } +}) +``` + +# --seed-- + +## --seed-contents-- + +```py +def add_time(start, duration): + + + + + + return new_time ``` # --solutions-- -```js -/** - Backend challenges don't need solutions, - because they would need to be tested against a full working project. - Please check our contributing guidelines to learn more. -*/ +```py +def add_time(start, duration, day=''): + start_arr = start[0:-3].split(':') + dur_arr = duration.split(':') + tail = '' + # converting to 24h format + if 'AM' in start: + if start_arr[0] == '12': + start_arr[0] = '00' + elif 'PM' in start: + if start_arr[0] == '12': + start_arr[0] = '12' + else: + start_arr[0] = f'{int(start_arr[0]) + 12}' + + # adding minutes + sum_m = int(start_arr[1]) + int(dur_arr[1]) + if sum_m > 59: + + if (sum_m - 60 * (sum_m//60)) < 10: + mins = f'0{(sum_m - 60 * (sum_m//60))}' + dur_arr[0] = int(dur_arr[0]) + sum_m//60 + + else: + mins = sum_m - 60 * (sum_m//60) + dur_arr[0] = int(dur_arr[0]) + sum_m//60 + else: + if sum_m < 10: + mins = f'0{sum_m}' + else: + mins = sum_m + + #adding hours + sum_h = int(start_arr[0]) + int(dur_arr[0]) + if sum_h < 24: + hours= sum_h + #time_24 = f'{hours}:{mins}' + else: + days_after = sum_h//24 + if days_after == 1: + hours = sum_h - 24 + tail = ' (next day)' + else: + hours = sum_h - 24 * days_after + tail = f' ({days_after} days later)' + + #converting back to AM/PM + if hours == 0: + hours = 12 + time = f'{hours}:{mins} AM' + final_time = f'{time}{tail}' + elif hours < 12: + time = f'{hours}:{mins} AM' + final_time = f'{time}{tail}' + else: + if hours > 12: + hours = hours - 12 + time = f'{hours}:{mins} PM' + final_time = f'{time}{tail}' + + #days of the week + week = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] + if day: + day = day.capitalize() + if not tail: + final_time = f'{time}, {day}' + elif tail == ' (next day)': + index = week.index(day) + 1 + if index == 7: + index = 0 + week_day = f', {week[index]}' + final_time = f'{time}{week_day}{tail}' + elif tail: + index = (week.index(day) + days_after) % 7 + week_day = f', {week[index]}' + final_time = f'{time}{week_day}{tail}' + + + print('\n') + print(final_time) + print('\n') + return final_time + ``` diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/add-a-new-element-to-a-binary-search-tree.md b/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/add-a-new-element-to-a-binary-search-tree.md index 58cc1763d59..2110f7220d2 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/add-a-new-element-to-a-binary-search-tree.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/add-a-new-element-to-a-binary-search-tree.md @@ -14,7 +14,7 @@ First, let's describe some common terminology we will encounter with trees. The To begin, we will discuss a particular type of tree, the binary tree. In fact, we will actually discuss a particular binary tree, a binary search tree. Let's describe what this means. While the tree data structure can have any number of branches at a single node, a binary tree can only have two branches for every node. Furthermore, a binary search tree is ordered with respect to the child subtrees, such that the value of each node in the left subtree is less than or equal to the value of the parent node, and the value of each node in the right subtree is greater than or equal to the value of the parent node. It's very helpful to visualize this relationship in order to understand it better: -
+
an example of a binairy search tree
Now this ordered relationship is very easy to see. Note that every value to the left of 8, the root node, is less than 8, and every value to the right is greater than 8. Also notice that this relationship applies to each of the subtrees as well. For example, the first left child is a subtree. 3 is the parent node, and it has exactly two child nodes — by the rules governing binary search trees, we know without even looking that the left child of this node (and any of its children) will be less than 3, and the right child (and any of its children) will be greater than 3 (but also less than the structure's root value), and so on. diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/depth-first-search.md b/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/depth-first-search.md index d03cf5a4b33..46cce024c8f 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/depth-first-search.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/depth-first-search.md @@ -16,7 +16,7 @@ Once it reaches one end of a path, the search will backtrack to the last node wi The animation below shows how the algorithm works. The algorithm starts with the top node and visits the nodes in the numbered order. - + Notice how, unlike breadth-first search, every time a node is visited, it doesn't visit all of its neighbors. Instead, it first visits one of its neighbors and continues down that path until there are no more nodes to be visited on that path. diff --git a/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/remove-an-element-from-a-max-heap.md b/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/remove-an-element-from-a-max-heap.md index 7731f012f88..083d14ea643 100644 --- a/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/remove-an-element-from-a-max-heap.md +++ b/curriculum/challenges/arabic/10-coding-interview-prep/data-structures/remove-an-element-from-a-max-heap.md @@ -88,49 +88,56 @@ The `remove` method should remove the greatest element from the max heap while m ```js function isHeap(arr, i, n) { - if (i >= (n - 1) / 2) { - return true; - } - if ( - arr[i] >= arr[2 * i + 1] && - arr[i] >= arr[2 * i + 2] && - isHeap(arr, 2 * i + 1, n) && - isHeap(arr, 2 * i + 2, n) - ) { - return true; - } - return false; + if( arr[i] < arr[2 * i + 1] || arr[i] < arr[2 * i + 2] ){ + return false; + } + if (i > (n - 1) / 2) { + return true; + } + if (isHeap(arr, 2 * i + 1, n) && isHeap(arr, 2 * i + 2, n)) { + return true; + } + return false; } + assert( (function () { let test = false; + if (typeof MaxHeap !== 'undefined') { test = new MaxHeap(); } else { return false; } - let max = Infinity; - const [result, vals] = [[], [2, 15, 3, 7, 12, 7, 10, 90]]; - vals.forEach((val) => test.insert(val)); - for (let i = 0; i < vals.length; i++) { - const curHeap = test.print(); - const arr = curHeap[0] === null ? curHeap.slice(1) : curHeap; - if (!isHeap(arr, 0, arr.length - 1)) { - return false; + + let max = Infinity; + const [result, vals] = [[], [9, 3, 5, 2, 15, 3, 7, 12, 7, 10, 90]]; + + vals.forEach((val) => test.insert(val)); + + for (let i = 0; i < vals.length; i++) { + const curHeap = test.print(); + const arr = curHeap[0] === null ? curHeap.slice(1) : curHeap; + + if (!isHeap(arr, 0, arr.length - 1)) { + return false; + } + + const removed = test.remove(); + if (!vals.includes(removed)) return false; + if (removed > max) return false + max = removed; + result.push(removed); } - const removed = test.remove(); - if (!vals.includes(removed)) return false; - if (removed > max) return false - max = removed; - result.push(removed); - } - for (let i = 0; i < vals.length; i++) { - if (!result.includes(vals[i])) { - return false; - } - } - return true + + for (let i = 0; i < vals.length; i++) { + if (!result.includes(vals[i])) { + return false; + } + } + + return true; })() ); ``` diff --git a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f3ef6e056bdde6ae6892ba2.md b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f3ef6e056bdde6ae6892ba2.md index 0ee64f04923..d88fa79d0a4 100644 --- a/curriculum/challenges/arabic/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f3ef6e056bdde6ae6892ba2.md +++ b/curriculum/challenges/arabic/14-responsive-web-design-22/learn-basic-css-by-building-a-cafe-menu/5f3ef6e056bdde6ae6892ba2.md @@ -23,7 +23,7 @@ assert(h1h2Selector); يجب عليك تعيين `font-family` إلى `Impact`. ```js -const hasFontFamily = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['font-family'] === 'Impact'); +const hasFontFamily = new __helpers.CSSHelp(document).getCSSRules().some(x => x.style['font-family'].toLowerCase() === 'impact'); assert(hasFontFamily); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md index 0ea718d968a..f017c81efce 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-cash-register-project/build-a-cash-register.md @@ -18,9 +18,9 @@ If you'd like to test your application with different values for `price` and `ci Your application should show different messages depending on the price of the item, the amount of cash provided by the customer, and the amount of cash in the drawer: -- `Status: INSUFFICIENT_FUNDS`: if `cash-in-drawer` is less than the change due, or if you cannot return the exact change. -- `Status: CLOSED`: if `cash-in-drawer` is equal to the change due. -- `Status: OPEN`: if `cash-in-drawer` is greater than the change due and you can return change, with the change due in coins and bills sorted in highest to lowest order. +- `"Status: INSUFFICIENT_FUNDS"`: if `cash-in-drawer` is less than the change due, or if you cannot return the exact change. +- `"Status: CLOSED"`: if `cash-in-drawer` is equal to the change due. +- `"Status: OPEN"`: if `cash-in-drawer` is greater than the change due and you can return change, with the change due in coins and bills sorted in highest to lowest order. | Currency Unit | Amount | |:-------------------:|:------------------:| @@ -38,43 +38,43 @@ Your application should show different messages depending on the price of the it **User Stories:** -1. You should have an `input` element with an `id` of `cash` -1. You should have a `div` element with an `id` of `change-due` -1. You should have a `button` element with an `id` of `purchase-btn` -1. When the value in the `#cash` element is less than `price`, an alert should appear with the text `Customer does not have enough money to purchase the item` -1. When the value in the `#cash` element is equal to `price`, the value in the `#change-due` element should be `No change due - customer paid with exact cash` -1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: OPEN QUARTER: $0.5` -1. When `price` is `3.26`, the value in the `#cash` element is `100`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: OPEN TWENTY: $60 TEN: $20 FIVE: $15 ONE: $1 QUARTER: $0.5 DIME: $0.2 PENNY: $0.04` -1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: INSUFFICIENT_FUNDS` -1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: INSUFFICIENT_FUNDS` -1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: CLOSED PENNY: $0.5` +1. You should have an `input` element with an `id` of `"cash"` +1. You should have a `div` element with an `id` of `"change-due"` +1. You should have a `button` element with an `id` of `"purchase-btn"` +1. When the value in the `#cash` element is less than `price`, an alert should appear with the text `"Customer does not have enough money to purchase the item"` +1. When the value in the `#cash` element is equal to `price`, the value in the `#change-due` element should be `"No change due - customer paid with exact cash"` +1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: OPEN QUARTER: $0.5"` +1. When `price` is `3.26`, the value in the `#cash` element is `100`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: OPEN TWENTY: $60 TEN: $20 FIVE: $15 ONE: $1 QUARTER: $0.5 DIME: $0.2 PENNY: $0.04"` +1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: INSUFFICIENT_FUNDS"` +1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: INSUFFICIENT_FUNDS"` +1. When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: CLOSED PENNY: $0.5"` Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! # --hints-- -You should have an `input` element with an `id` of `cash`. +You should have an `input` element with an `id` of `"cash"`. ```js const el = document.getElementById('cash'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'input'); ``` -You should have a `div` element with an `id` of `change-due`. +You should have a `div` element with an `id` of `"change-due"`. ```js const el = document.getElementById('change-due'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'div'); ``` -You should have a `button` element with an `id` of `purchase-btn`. +You should have a `button` element with an `id` of `"purchase-btn"`. ```js const el = document.getElementById('purchase-btn'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'button'); ``` -When the value in the `#cash` element is less than `price`, an alert should appear with the text `Customer does not have enough money to purchase the item`. +When the value in the `#cash` element is less than `price`, an alert should appear with the text `"Customer does not have enough money to purchase the item"`. ```js const cashInput = document.getElementById('cash'); @@ -89,7 +89,7 @@ purchaseBtn.click(); assert.strictEqual(alertMessage.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'customer does not have enough money to purchase the item'); ``` -When the value in the `#cash` element is equal to `price`, the value in the `#change-due` element should be `No change due - customer paid with exact cash`. +When the value in the `#cash` element is equal to `price`, the value in the `#change-due` element should be `"No change due - customer paid with exact cash"`. ```js const cashInput = document.getElementById('cash'); @@ -103,7 +103,7 @@ purchaseBtn.click(); assert.strictEqual(changeDueDiv.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'no change due - customer paid with exact cash'); ``` -When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: OPEN QUARTER: $0.5`. +When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: OPEN QUARTER: $0.5"`. ```js const cashInput = document.getElementById('cash'); @@ -119,7 +119,7 @@ purchaseBtn.click(); assert.isTrue(expected.every(str => changeDueDiv.innerText.trim().toLowerCase().includes(str.toLowerCase()))); ``` -When `price` is `3.26`, the value in the `#cash` element is `100`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: OPEN TWENTY: $60 TEN: $20 FIVE: $15 ONE: $1 QUARTER: $0.5 DIME: $0.2 PENNY: $0.04`. +When `price` is `3.26`, the value in the `#cash` element is `100`, `cid` is `[["PENNY", 1.01], ["NICKEL", 2.05], ["DIME", 3.1], ["QUARTER", 4.25], ["ONE", 90], ["FIVE", 55], ["TEN", 20], ["TWENTY", 60], ["ONE HUNDRED", 100]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: OPEN TWENTY: $60 TEN: $20 FIVE: $15 ONE: $1 QUARTER: $0.5 DIME: $0.2 PENNY: $0.04"`. ```js const cashInput = document.getElementById('cash'); @@ -135,7 +135,7 @@ purchaseBtn.click(); assert.isTrue(expected.every(str => changeDueDiv.innerText.trim().toLowerCase().includes(str.toLowerCase()))); ``` -When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: INSUFFICIENT_FUNDS` +When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: INSUFFICIENT_FUNDS"` ```js const cashInput = document.getElementById('cash'); @@ -150,7 +150,7 @@ purchaseBtn.click(); assert.strictEqual(changeDueDiv.innerText.trim().toLowerCase(), 'status: insufficient_funds'); ``` -When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: INSUFFICIENT_FUNDS`. +When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.01], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 1], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: INSUFFICIENT_FUNDS"`. ```js const cashInput = document.getElementById('cash'); @@ -165,7 +165,7 @@ purchaseBtn.click(); assert.strictEqual(changeDueDiv.innerText.trim().toLowerCase(), 'status: insufficient_funds'); ``` -When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `Status: CLOSED PENNY: $0.5`. +When `price` is `19.5`, the value in the `#cash` element is `20`, `cid` is `[["PENNY", 0.5], ["NICKEL", 0], ["DIME", 0], ["QUARTER", 0], ["ONE", 0], ["FIVE", 0], ["TEN", 0], ["TWENTY", 0], ["ONE HUNDRED", 0]]`, and the `#purchase-btn` element is clicked, the value in the `#change-due` element should be `"Status: CLOSED PENNY: $0.5"`. ```js const cashInput = document.getElementById('cash'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-palindrome-checker-project/build-a-palindrome-checker.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-palindrome-checker-project/build-a-palindrome-checker.md index 3c066c2d51f..a2750bb1b75 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-palindrome-checker-project/build-a-palindrome-checker.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-palindrome-checker-project/build-a-palindrome-checker.md @@ -16,36 +16,36 @@ A palindrome is a word or phrase that can be read the same way forwar **User Stories:** -1. You should have an `input` element with an `id` of `text-input` -1. You should have a `button` element with an `id` of `check-btn` -1. You should have a `div` element with an `id` of `result` -1. When you click on the `#check-btn` element without entering a value into the `#text-input` element, an alert should appear with the text `Please input a value` -1. When the `#text-input` element only contains the letter `A` and the `#check-btn` element is clicked, the `#result` element should contain the text `A is a palindrome` -1. When the `#text-input` element contains the text `eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `eye is a palindrome` -1. When the `#text-input` element contains the text `_eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `_eye is a palindrome` -1. When the `#text-input` element contains the text `race car` and the `#check-btn` element is clicked, the `#result` element should contain the text `race car is a palindrome` -1. When the `#text-input` element contains the text `not a palindrome` and the `#check-btn` element is clicked, the `#result` element should contain the text `not a palindrome is not a palindrome` -1. When the `#test-input` element contains the text `A man, a plan, a canal. Panama` and the `#check-btn` element is clicked, the `#result` element should contain the text `A man, a plan, a canal. Panama is a palindrome` -1. When the `#text-input` element contains the text `never odd or even` and the `#check-btn` element is clicked, the `#result` element should contain the text `never odd or even is a palindrome` -1. When the `#text-input` element contains the text `nope` and the `#check-btn` element is clicked, the `#result` element should contain the text `nope is not a palindrome` -1. When the `#text-input` element contains the text `almostomla` and the `#check-btn` element is clicked, the `#result` element should contain the text `almostomla is not a palindrome` -1. When the `#text-input` element contains the text `My age is 0, 0 si ega ym.` and the `#check-btn` element is clicked, the `#result` element should contain the text `My age is 0, 0 si ega ym. is a palindrome` -1. When the `#text-input` element contains the text `1 eye for of 1 eye.` and the `#check-btn` element is clicked, the `#result` element should contain the text `1 eye for of 1 eye. is not a palindrome` -1. When the `#text-input` element contains the text `0_0 (: /-\ :) 0-0` and the `#check-btn` element is clicked, the `#result` element should contain the text `0_0 (: /-\ :) 0-0 is a palindrome` -1. When the `#text-input` element contains the text `five|\_/|four` and the `#check-btn` element is clicked, the `#result` element should contain the text `five|\_/|four is not a palindrome` +1. You should have an `input` element with an `id` of `"text-input"` +1. You should have a `button` element with an `id` of `"check-btn"` +1. You should have a `div` element with an `id` of `"result"` +1. When you click on the `#check-btn` element without entering a value into the `#text-input` element, an alert should appear with the text `"Please input a value"` +1. When the `#text-input` element only contains the letter `A` and the `#check-btn` element is clicked, the `#result` element should contain the text `"A is a palindrome"` +1. When the `#text-input` element contains the text `eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `"eye is a palindrome"` +1. When the `#text-input` element contains the text `_eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `"_eye is a palindrome"` +1. When the `#text-input` element contains the text `race car` and the `#check-btn` element is clicked, the `#result` element should contain the text `"race car is a palindrome"` +1. When the `#text-input` element contains the text `not a palindrome` and the `#check-btn` element is clicked, the `#result` element should contain the text `"not a palindrome is not a palindrome"` +1. When the `#test-input` element contains the text `A man, a plan, a canal. Panama` and the `#check-btn` element is clicked, the `#result` element should contain the text `"A man, a plan, a canal. Panama is a palindrome"` +1. When the `#text-input` element contains the text `never odd or even` and the `#check-btn` element is clicked, the `#result` element should contain the text `"never odd or even is a palindrome"` +1. When the `#text-input` element contains the text `nope` and the `#check-btn` element is clicked, the `#result` element should contain the text `"nope is not a palindrome"` +1. When the `#text-input` element contains the text `almostomla` and the `#check-btn` element is clicked, the `#result` element should contain the text `"almostomla is not a palindrome"` +1. When the `#text-input` element contains the text `My age is 0, 0 si ega ym.` and the `#check-btn` element is clicked, the `#result` element should contain the text `"My age is 0, 0 si ega ym. is a palindrome"` +1. When the `#text-input` element contains the text `1 eye for of 1 eye.` and the `#check-btn` element is clicked, the `#result` element should contain the text `"1 eye for of 1 eye. is not a palindrome"` +1. When the `#text-input` element contains the text `0_0 (: /-\ :) 0-0` and the `#check-btn` element is clicked, the `#result` element should contain the text `"0_0 (: /-\ :) 0-0 is a palindrome"` +1. When the `#text-input` element contains the text `five|\_/|four` and the `#check-btn` element is clicked, the `#result` element should contain the text `"five|\_/|four is not a palindrome"` Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! # --hints-- -You should have an `input` element with an `id` of `text-input`. +You should have an `input` element with an `id` of `"text-input"`. ```js const el = document.getElementById('text-input'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'input'); ``` -You should have a `button` element with an `id` of `check-btn`. +You should have a `button` element with an `id` of `"check-btn"`. ```js const el = document.getElementById('check-btn'); @@ -59,7 +59,7 @@ const el = document.getElementById('result'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'div'); ``` -When you click on the `#check-btn` element without entering a value into the `#text-input` element, an alert should appear with the text `Please input a value`. +When you click on the `#check-btn` element without entering a value into the `#text-input` element, an alert should appear with the text `"Please input a value"`. ```js const inputEl = document.getElementById('text-input'); @@ -72,7 +72,7 @@ checkBtn.click(); assert.strictEqual(alertMessage.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please input a value'); ``` -When the `#text-input` element only contains the letter `A` and the `#check-btn` element is clicked, the `#result` element should contain the text `A is a palindrome`. +When the `#text-input` element only contains the letter `A` and the `#check-btn` element is clicked, the `#result` element should contain the text `"A is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -84,7 +84,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'a is a palindrome'); ``` -When the `#text-input` element contains the text `eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `eye is a palindrome`. +When the `#text-input` element contains the text `eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `"eye is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -96,7 +96,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'eye is a palindrome'); ``` -When the `#text-input` element contains the text `_eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `_eye is a palindrome`. +When the `#text-input` element contains the text `_eye` and the `#check-btn` element is clicked, the `#result` element should contain the text `"_eye is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -108,7 +108,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), '_eye is a palindrome'); ``` -When the `#text-input` element contains the text `race car` and the `#check-btn` element is clicked, the `#result` element should contain the text `race car is a palindrome`. +When the `#text-input` element contains the text `race car` and the `#check-btn` element is clicked, the `#result` element should contain the text `"race car is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -120,7 +120,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'race car is a palindrome'); ``` -When the `#text-input` element contains the text `not a palindrome` and the `#check-btn` element is clicked, the `#result` element should contain the text `not a palindrome is not a palindrome`. +When the `#text-input` element contains the text `not a palindrome` and the `#check-btn` element is clicked, the `#result` element should contain the text `"not a palindrome is not a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -132,7 +132,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'not a palindrome is not a palindrome'); ``` -When the `#test-input` element contains the text `A man, a plan, a canal. Panama` and the `#check-btn` element is clicked, the `#result` element should contain the text `A man, a plan, a canal. Panama is a palindrome`. +When the `#test-input` element contains the text `A man, a plan, a canal. Panama` and the `#check-btn` element is clicked, the `#result` element should contain the text `"A man, a plan, a canal. Panama is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -144,7 +144,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'a man, a plan, a canal. panama is a palindrome'); ``` -When the `#text-input` element contains the text `never odd or even` and the `#check-btn` element is clicked, the `#result` element should contain the text `never odd or even is a palindrome`. +When the `#text-input` element contains the text `never odd or even` and the `#check-btn` element is clicked, the `#result` element should contain the text `"never odd or even is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -156,7 +156,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'never odd or even is a palindrome'); ``` -When the `#text-input` element contains the text `nope` and the `#check-btn` element is clicked, the `#result` element should contain the text `nope is not a palindrome`. +When the `#text-input` element contains the text `nope` and the `#check-btn` element is clicked, the `#result` element should contain the text `"nope is not a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -168,7 +168,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'nope is not a palindrome'); ``` -When the `#text-input` element contains the text `almostomla` and the `#check-btn` element is clicked, the `#result` element should contain the text `almostomla is not a palindrome`. +When the `#text-input` element contains the text `almostomla` and the `#check-btn` element is clicked, the `#result` element should contain the text `"almostomla is not a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -180,7 +180,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'almostomla is not a palindrome'); ``` -When the `#text-input` element contains the text `My age is 0, 0 si ega ym.` and the `#check-btn` element is clicked, the `#result` element should contain the text `My age is 0, 0 si ega ym. is a palindrome`. +When the `#text-input` element contains the text `My age is 0, 0 si ega ym.` and the `#check-btn` element is clicked, the `#result` element should contain the text `"My age is 0, 0 si ega ym. is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -192,7 +192,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'my age is 0, 0 si ega ym. is a palindrome'); ``` -When the `#text-input` element contains the text `1 eye for of 1 eye.` and the `#check-btn` element is clicked, the `#result` element should contain the text `1 eye for of 1 eye. is not a palindrome`. +When the `#text-input` element contains the text `1 eye for of 1 eye.` and the `#check-btn` element is clicked, the `#result` element should contain the text `"1 eye for of 1 eye. is not a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -204,7 +204,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), '1 eye for of 1 eye. is not a palindrome'); ``` -When the `#text-input` element contains the text `0_0 (: /-\ :) 0-0` and the `#check-btn` element is clicked, the `#result` element should contain the text `0_0 (: /-\ :) 0-0 is a palindrome`. +When the `#text-input` element contains the text `0_0 (: /-\ :) 0-0` and the `#check-btn` element is clicked, the `#result` element should contain the text `"0_0 (: /-\ :) 0-0 is a palindrome"`. ```js const inputEl = document.getElementById('text-input'); @@ -216,7 +216,7 @@ checkBtn.click(); assert.strictEqual(resultEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), '0_0 (: /-\ :) 0-0 is a palindrome'); ``` -When the `#text-input` element contains the text `five|\_/|four` and the `#check-btn` element is clicked, the `#result` element should contain the text `five|\_/|four is not a palindrome`. +When the `#text-input` element contains the text `five|\_/|four` and the `#check-btn` element is clicked, the `#result` element should contain the text `"five|\_/|four is not a palindrome"`. ```js const inputEl = document.getElementById('text-input'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-pokemon-search-app-project/build-a-pokemon-search-app.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-pokemon-search-app-project/build-a-pokemon-search-app.md index 94c0f6cce14..3e37aae1f08 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-pokemon-search-app-project/build-a-pokemon-search-app.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-pokemon-search-app-project/build-a-pokemon-search-app.md @@ -14,22 +14,22 @@ In this project, you'll build an app that will search for Pokémon by name or ID **User Stories:** -1. You should have an `input` element with an `id` of `search-input` -1. You should have a `button` element with an `id` of `search-button` -1. You should have an element with an `id` of `pokemon-name` -1. You should have an element with an `id` of `pokemon-id` -1. You should have an element with an `id` of `weight` -1. You should have an element with an `id` of `height` -1. You should have an element with an `id` of `types` -1. You should have an element with an `id` of `hp` -1. You should have an element with an `id` of `attack` -1. You should have an element with an `id` of `defense` -1. You should have an element with an `id` of `special-attack` -1. You should have an element with an `id` of `special-defense` -1. You should have an element with an `id` of `speed` -1. When the `#search-input` element contains the value `Red` and the `#search-button` element is clicked, an alert should appear with the text `Pokémon not found` +1. You should have an `input` element with an `id` of `"search-input"` +1. You should have a `button` element with an `id` of `"search-button` +1. You should have an element with an `id` of `"pokemon-name"` +1. You should have an element with an `id` of `"pokemon-id"` +1. You should have an element with an `id` of `"weight"` +1. You should have an element with an `id` of `"height"` +1. You should have an element with an `id` of `"types"` +1. You should have an element with an `id` of `"hp"` +1. You should have an element with an `id` of `"attack"` +1. You should have an element with an `id` of `"defense"` +1. You should have an element with an `id` of `"special-attack"` +1. You should have an element with an `id` of `"special-defense"` +1. You should have an element with an `id` of `"speed"` +1. When the `#search-input` element contains the value `Red` and the `#search-button` element is clicked, an alert should appear with the text `"Pokémon not found"` 1. When the `#search-input` element contains the value `Pikachu` and the `#search-button` element is clicked, the values in the `#pokemon-name`, `#pokemon-id`, `#weight`, `#height`, `#hp`, `#attack`, `#defense`, `#special-attack`, `#special-defense`, and `#speed` elements should be `PIKACHU`, `#25` or `25`, `Weight: 60` or `60`, `Height: 4` or `4`, `35`, `55`, `40`, `50`, `50`, and `90`, respectively -1. When the `#search-input` element contains the value `Pikachu` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `sprite` and the `src` set to the Pokémon's `front_default` sprite to the page +1. When the `#search-input` element contains the value `Pikachu` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `"sprite"` and the `src` set to the Pokémon's `front_default` sprite to the page 1. When the `#search-input` element contains the value `Pikachu` and the `#search-button` element is clicked, the `#types` element should contain a single inner element with the value `ELECTRIC`. The `#types` element content should be cleared between searches 1. When the `#search-input` element contains the value `94` and the `#search-button` element is clicked, the values in the `#pokemon-name`, `#pokemon-id`, `#weight`, `#height`, `#hp`, `#attack`, `#defense`, `#special-attack`, `#special-defense`, and `#speed`elements should be `GENGAR`, `#94` or `94`, `Weight: 405` or `405`, `Height: 15` or `15`, `60`, `65`, `60`, `130`, `75`, and `110`, respectively 1. When the `#search-input` element contains the value `94` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `sprite` and the `src` set to the Pokémon's `front_default` sprite to the page @@ -41,7 +41,7 @@ Fulfill the user stories and pass all the tests below to complete this project. # --hints-- -You should have an `input` element with an `id` of `search-input` and is **required**. +You should have an `input` element with an `id` of `"search-input"` and is **required**. ```js const el = document.getElementById('search-input'); @@ -49,91 +49,91 @@ assert.strictEqual(el?.nodeName?.toLowerCase(), 'input'); assert.isTrue(el?.required); ``` -You should have a `button` element with an `id` of `search-button`. +You should have a `button` element with an `id` of `"search-button"`. ```js const el = document.getElementById('search-button'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'button'); ``` -You should have an element with an `id` of `pokemon-name`. +You should have an element with an `id` of `"pokemon-name"`. ```js const el = document.getElementById('pokemon-name'); assert.exists(el); ``` -You should have an element with an `id` of `pokemon-id`. +You should have an element with an `id` of `"pokemon-id"`. ```js const el = document.getElementById('pokemon-id'); assert.exists(el); ``` -You should have an element with an `id` of `weight`. +You should have an element with an `id` of `"weight"`. ```js const el = document.getElementById('weight'); assert.exists(el); ``` -You should have an element with an `id` of `height`. +You should have an element with an `id` of `"height"`. ```js const el = document.getElementById('height'); assert.exists(el); ``` -You should have an element with an `id` of `types`. +You should have an element with an `id` of `"types"`. ```js const el = document.getElementById('types'); assert.exists(el); ``` -You should have an element with an `id` of `hp`. +You should have an element with an `id` of `"hp"`. ```js const el = document.getElementById('hp'); assert.exists(el); ``` -You should have an element with an `id` of `attack`. +You should have an element with an `id` of `"attack"`. ```js const el = document.getElementById('attack'); assert.exists(el); ``` -You should have an element with an `id` of `defense`. +You should have an element with an `id` of `"defense"`. ```js const el = document.getElementById('defense'); assert.exists(el); ``` -You should have an element with an `id` of `special-attack`. +You should have an element with an `id` of `"special-attack"`. ```js const el = document.getElementById('special-attack'); assert.exists(el); ``` -You should have an element with an `id` of `special-defense`. +You should have an element with an `id` of `"special-defense"`. ```js const el = document.getElementById('special-defense'); assert.exists(el); ``` -You should have an element with an `id` of `speed`. +You should have an element with an `id` of `"speed"`. ```js const el = document.getElementById('speed'); assert.exists(el); ``` -When the `#search-input` element contains the value `Red` and the `#search-button` element is clicked, an alert should appear with the text `Pokémon not found`. +When the `#search-input` element contains the value `Red` and the `#search-button` element is clicked, an alert should appear with the text `"Pokémon not found"`. ```js async () => { @@ -201,7 +201,7 @@ async () => { }; ``` -When the `#search-input` element contains the value `Pikachu` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `sprite` and the `src` set to the Pokémon's `front_default` sprite to the page. +When the `#search-input` element contains the value `Pikachu` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `"sprite"` and the `src` set to the Pokémon's `front_default` sprite to the page. ```js async () => { @@ -294,7 +294,7 @@ async () => { }; ``` -When the `#search-input` element contains the value `94` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `sprite` and the `src` set to the Pokémon's `front_default` sprite to the page. +When the `#search-input` element contains the value `94` and the `#search-button` element is clicked, you should add an `img` element with the `id` of `"sprite"` and the `src` set to the Pokémon's `front_default` sprite to the page. ```js async () => { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-roman-numeral-converter-project/build-a-roman-numeral-converter.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-roman-numeral-converter-project/build-a-roman-numeral-converter.md index 09faf0f67e4..98c9cd330c8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-roman-numeral-converter-project/build-a-roman-numeral-converter.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-roman-numeral-converter-project/build-a-roman-numeral-converter.md @@ -30,44 +30,44 @@ Roman numerals are based on seven symbols and can be written using various combi **User Stories:** -1. You should have an `input` element with an `id` of `number` -1. You should have a `button` element with an `id` of `convert-btn` +1. You should have an `input` element with an `id` of `"number"` +1. You should have a `button` element with an `id` of `"convert-btn"` 1. You should have a `div` element with an `id` of `output` -1. When you click on the `#convert-btn` element without entering a value into the `#number` element, the `#output` element should contain the text `Please enter a valid number` -1. When the `#number` element contains the number `-1` and the `#convert-btn` element is clicked, the `#output` element should contain the text `Please enter a number greater than or equal to 1` -1. When the `#number` element contains the number `4000` or greater and the `#convert-btn` element is clicked, the `#output` element should contain the text `Please enter a number less than or equal to 3999` -1. When the `#number` element contains the number `9` and the `#convert-btn` element is clicked, the `#output` element should contain the text `IX` -1. When the `#number` element contains the number `16` and the `#convert-btn` element is clicked, the `#output` element should contain the text `XVI` -1. When the `#number` element contains the number `649` and the `#convert-btn` element is clicked, the `#output` element should contain the text `DCXLIX` -1. When the `#number` element contains the number `1023` and the `#convert-btn` element is clicked, the `#output` element should contain the text `MXXIII` -1. When the `#number` element contains the number `3999` and the `#convert-btn` element is clicked, the `#output` element should contain the text `MMMCMXCIX` +1. When you click on the `#convert-btn` element without entering a value into the `#number` element, the `#output` element should contain the text `"Please enter a valid number"` +1. When the `#number` element contains the number `-1` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"Please enter a number greater than or equal to 1"` +1. When the `#number` element contains the number `4000` or greater and the `#convert-btn` element is clicked, the `#output` element should contain the text `"Please enter a number less than or equal to 3999"` +1. When the `#number` element contains the number `9` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"IX"` +1. When the `#number` element contains the number `16` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"XVI"` +1. When the `#number` element contains the number `649` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"DCXLIX"` +1. When the `#number` element contains the number `1023` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"MXXIII"` +1. When the `#number` element contains the number `3999` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"MMMCMXCIX"` Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! # --hints-- -You should have an `input` element with an `id` of `number`. +You should have an `input` element with an `id` of `"number"`. ```js const el = document.getElementById('number'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'input'); ``` -You should have a `button` element with an `id` of `convert-btn`. +You should have a `button` element with an `id` of `"convert-btn"`. ```js const el = document.getElementById('convert-btn'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'button'); ``` -You should have a `div` element with an `id` of `output`. +You should have a `div` element with an `id` of `"output"`. ```js const el = document.getElementById('output'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'div'); ``` -When you click on the `#convert-btn` element without entering a value into the `#number` element, the `#output` element should contain the text `Please enter a valid number`. +When you click on the `#convert-btn` element without entering a value into the `#number` element, the `#output` element should contain the text `"Please enter a valid number"`. ```js const numberInputEl = document.getElementById('number'); @@ -79,7 +79,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please enter a valid number'); ``` -When the `#number` element contains the number `-1` and the `#convert-btn` element is clicked, the `#output` element should contain the text `Please enter a number greater than or equal to 1` +When the `#number` element contains the number `-1` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"Please enter a number greater than or equal to 1"`. ```js const numberInputEl = document.getElementById('number'); @@ -91,7 +91,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please enter a number greater than or equal to 1'); ``` -When the `#number` element contains the number `4000` or greater and the `#convert-btn` element is clicked, the `#output` element should contain the text `Please enter a number less than or equal to 3999`. +When the `#number` element contains the number `4000` or greater and the `#convert-btn` element is clicked, the `#output` element should contain the text `"Please enter a number less than or equal to 3999"`. ```js const numberInputEl = document.getElementById('number'); @@ -103,7 +103,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim().replace(/[.,?!]+$/g, '').toLowerCase(), 'please enter a number less than or equal to 3999'); ``` -When the `#number` element contains the number `9` and the `#convert-btn` element is clicked, the `#output` element should contain the text `IX`. +When the `#number` element contains the number `9` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"IX"`. ```js const numberInputEl = document.getElementById('number'); @@ -115,7 +115,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim(), 'IX'); ``` -When the `#number` element contains the number `16` and the `#convert-btn` element is clicked, the `#output` element should contain the text `XVI`. +When the `#number` element contains the number `16` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"XVI"`. ```js const numberInputEl = document.getElementById('number'); @@ -127,7 +127,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim(), 'XVI'); ``` -When the `#number` element contains the number `649` and the `#convert-btn` element is clicked, the `#output` element should contain the text `DCXLIX`. +When the `#number` element contains the number `649` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"DCXLIX"`. ```js const numberInputEl = document.getElementById('number'); @@ -139,7 +139,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim(), 'DCXLIX'); ``` -When the `#number` element contains the number `1023` and the `#convert-btn` element is clicked, the `#output` element should contain the text `MXXIII`. +When the `#number` element contains the number `1023` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"MXXIII"`. ```js const numberInputEl = document.getElementById('number'); @@ -151,7 +151,7 @@ convertBtnEl.click(); assert.strictEqual(outputEl.innerText.trim(), 'MXXIII'); ``` -When the `#number` element contains the number `3999` and the `#convert-btn` element is clicked, the `#output` element should contain the text `MMMCMXCIX`. +When the `#number` element contains the number `3999` and the `#convert-btn` element is clicked, the `#output` element should contain the text `"MMMCMXCIX"`. ```js const numberInputEl = document.getElementById('number'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-telephone-number-validator-project/build-a-telephone-number-validator.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-telephone-number-validator-project/build-a-telephone-number-validator.md index f506b3b17d4..f50f70d4a56 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-telephone-number-validator-project/build-a-telephone-number-validator.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/build-a-telephone-number-validator-project/build-a-telephone-number-validator.md @@ -26,74 +26,74 @@ Note that the area code is required. Also, if the country code is provided, you **User Stories:** -1. You should have an `input` element with an `id` of `user-input` -1. You should have a `button` element with an `id` of `check-btn` -1. You should have a `button` element with an `id` of `clear-btn` -1. You should have a `div` element with an `id` of `results-div` -1. When you click on the `#check-btn` element without entering a value into the `#user-input` element, an alert should appear with the text `Please provide a phone number` +1. You should have an `input` element with an `id` of `"user-input"` +1. You should have a `button` element with an `id` of `"check-btn` +1. You should have a `button` element with an `id` of `"clear-btn"` +1. You should have a `div` element with an `id` of `"results-div"` +1. When you click on the `#check-btn` element without entering a value into the `#user-input` element, an alert should appear with the text `"Please provide a phone number"` 1. When you click on the `#clear-btn` element, the content within the `#results-div` element should be removed -1. When the `#user-input` element contains `1 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 555-555-5555` -1. When the `#user-input` element contains `1 (555) 555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 (555) 555-5555` -1. When the `#user-input` element contains `5555555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 5555555555` -1. When the `#user-input` element contains `555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 555-555-5555` -1. When the `#user-input` element contains `(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: (555)555-5555` -1. When the `#user-input` element contains `1(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1(555)555-5555` -1. When the `#user-input` element contains `555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 555-5555` -1. When the `#user-input` element contains `5555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 5555555` -1. When the `#user-input` element contains `1 555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 1 555)555-5555` -1. When the `#user-input` element contains `1 555 555 5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 555 555 5555` -1. When the `#user-input` element contains `1 456 789 4444` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 456 789 4444` -1. When `#user-input` contains `123**&!!asdf#` and `#check-btn` is clicked, `#results-div` should contain the text `Invalid US number: 123**&!!asdf#` -1. When the `#user-input` element contains `55555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 55555555` -1. When the `#user-input` element contains `(6054756961)` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: (6054756961)` -1. When the `#user-input` element contains `2 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2 (757) 622-7382` -1. When the `#user-input` element contains `0 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 0 (757) 622-7382` -1. When the `#user-input` element contains `-1 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: -1 (757) 622-7382` -1. When the `#user-input` element contains `2 757 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2 757 622-7382` -1. When the `#user-input` element contains `10 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 10 (757) 622-7382` -1. When the `#user-input` element contains `27576227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 27576227382` -1. When the `#user-input` element contains `(275)76227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: (275)76227382` -1. When the `#user-input` element contains `2(757)6227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2(757)6227382` -1. When the `#user-input` element contains `2(757)622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2(757)622-7382` -1. When the `#user-input` element contains `555)-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 555)-555-5555` -1. When the `#user-input` element contains `(555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: (555-555-5555` -1. When `#user-input` contains `(555)5(55?)-5555` and `#check-btn` is clicked, `#results-div` should contain the text `Invalid US number: (555)5(55?)-5555` -1. When the `#user-input` element contains `55 55-55-555-5` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 55 55-55-555-5` -1. When the `#user-input` element contains `11 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 11 555-555-5555` +1. When the `#user-input` element contains `1 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 555-555-5555"` +1. When the `#user-input` element contains `1 (555) 555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 (555) 555-5555"` +1. When the `#user-input` element contains `5555555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 5555555555"` +1. When the `#user-input` element contains `555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 555-555-5555" +1. When the `#user-input` element contains `(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: (555)555-5555"` +1. When the `#user-input` element contains `1(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1(555)555-5555"` +1. When the `#user-input` element contains `555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 555-5555"` +1. When the `#user-input` element contains `5555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 5555555"` +1. When the `#user-input` element contains `1 555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 1 555)555-5555"` +1. When the `#user-input` element contains `1 555 555 5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 555 555 5555"` +1. When the `#user-input` element contains `1 456 789 4444` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 456 789 4444"` +1. When `#user-input` contains `123**&!!asdf#` and `#check-btn` is clicked, `#results-div` should contain the text `"Invalid US number: 123**&!!asdf#"` +1. When the `#user-input` element contains `55555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 55555555"` +1. When the `#user-input` element contains `(6054756961)` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: (6054756961)"` +1. When the `#user-input` element contains `2 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2 (757) 622-7382"` +1. When the `#user-input` element contains `0 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 0 (757) 622-7382"` +1. When the `#user-input` element contains `-1 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: -1 (757) 622-7382"` +1. When the `#user-input` element contains `2 757 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2 757 622-7382"` +1. When the `#user-input` element contains `10 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 10 (757) 622-7382"` +1. When the `#user-input` element contains `27576227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 27576227382"` +1. When the `#user-input` element contains `(275)76227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: (275)76227382"` +1. When the `#user-input` element contains `2(757)6227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2(757)6227382"` +1. When the `#user-input` element contains `2(757)622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2(757)622-7382"` +1. When the `#user-input` element contains `555)-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 555)-555-5555"` +1. When the `#user-input` element contains `(555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: (555-555-5555"` +1. When `#user-input` contains `(555)5(55?)-5555` and `#check-btn` is clicked, `#results-div` should contain the text `"Invalid US number: (555)5(55?)-5555"` +1. When the `#user-input` element contains `55 55-55-555-5` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 55 55-55-555-5"` +1. When the `#user-input` element contains `11 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 11 555-555-5555"` Fulfill the user stories and pass all the tests below to complete this project. Give it your own personal style. Happy Coding! # --hints-- -You should have an `input` element with an `id` of `user-input`. +You should have an `input` element with an `id` of `"user-input"`. ```js const el = document.getElementById('user-input'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'input'); ``` -You should have a `button` element with an `id` of `check-btn`. +You should have a `button` element with an `id` of `"check-btn"`. ```js const el = document.getElementById('check-btn'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'button'); ``` -You should have a `button` element with an `id` of `clear-btn`. +You should have a `button` element with an `id` of `"clear-btn"`. ```js const el = document.getElementById('clear-btn'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'button'); ``` -You should have a `div` element with an `id` of `results-div`. +You should have a `div` element with an `id` of `"results-div"`. ```js const el = document.getElementById('results-div'); assert.strictEqual(el?.nodeName?.toLowerCase(), 'div'); ``` -When you click on the `#check-btn` element without entering a value into the `#user-input` element, an alert should appear with the text `Please provide a phone number`. +When you click on the `#check-btn` element without entering a value into the `#user-input` element, an alert should appear with the text `"Please provide a phone number"`. ```js const userInput = document.getElementById('user-input'); @@ -118,7 +118,7 @@ clearBtn.click(); assert.isEmpty(resultsDiv.textContent); ``` -When the `#user-input` element contains `1 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 555-555-5555`. +When the `#user-input` element contains `1 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 555-555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -131,7 +131,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 1 555-555-5555'); ``` -When the `#user-input` element contains `1 (555) 555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 (555) 555-5555`. +When the `#user-input` element contains `1 (555) 555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 (555) 555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -144,7 +144,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 1 (555) 555-5555'); ``` -When the `#user-input` element contains `5555555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 5555555555`. +When the `#user-input` element contains `5555555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 5555555555"`. ```js const userInput = document.getElementById('user-input'); @@ -157,7 +157,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 5555555555'); ``` -When the `#user-input` element contains `555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 555-555-5555`. +When the `#user-input` element contains `555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 555-555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -170,7 +170,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 555-555-5555'); ``` -When the `#user-input` element contains `(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: (555)555-5555`. +When the `#user-input` element contains `(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: (555)555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -183,7 +183,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: (555)555-5555'); ``` -When the `#user-input` element contains `1(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1(555)555-5555`. +When the `#user-input` element contains `1(555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1(555)555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -196,7 +196,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 1(555)555-5555'); ``` -When the `#user-input` element contains `555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 555-5555`. +When the `#user-input` element contains `555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -209,7 +209,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 555-5555'); ``` -When the `#user-input` element contains `5555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 5555555`. +When the `#user-input` element contains `5555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 5555555"`. ```js const userInput = document.getElementById('user-input'); @@ -222,7 +222,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 5555555'); ``` -When the `#user-input` element contains `1 555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 1 555)555-5555`. +When the `#user-input` element contains `1 555)555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 1 555)555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -235,7 +235,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 1 555)555-5555'); ``` -When the `#user-input` element contains `1 555 555 5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 555 555 5555`. +When the `#user-input` element contains `1 555 555 5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 555 555 5555"`. ```js const userInput = document.getElementById('user-input'); @@ -248,7 +248,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 1 555 555 5555'); ``` -When the `#user-input` element contains `1 456 789 4444` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Valid US number: 1 456 789 4444`. +When the `#user-input` element contains `1 456 789 4444` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Valid US number: 1 456 789 4444"`. ```js const userInput = document.getElementById('user-input'); @@ -261,7 +261,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'valid us number: 1 456 789 4444'); ``` -When `#user-input` contains `123**&!!asdf#` and `#check-btn` is clicked, `#results-div` should contain the text `Invalid US number: 123**&!!asdf#`. +When `#user-input` contains `123**&!!asdf#` and `#check-btn` is clicked, `#results-div` should contain the text `"Invalid US number: 123**&!!asdf#"`. ```js const userInput = document.getElementById('user-input'); @@ -274,7 +274,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 123**&!!asdf#'); ``` -When the `#user-input` element contains `55555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 55555555`. +When the `#user-input` element contains `55555555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 55555555"`. ```js const userInput = document.getElementById('user-input'); @@ -287,7 +287,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 55555555'); ``` -When the `#user-input` element contains `(6054756961)` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: (6054756961)`. +When the `#user-input` element contains `(6054756961)` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: (6054756961)"`. ```js const userInput = document.getElementById('user-input'); @@ -300,7 +300,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: (6054756961)'); ``` -When the `#user-input` element contains `2 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2 (757) 622-7382`. +When the `#user-input` element contains `2 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2 (757) 622-7382"`. ```js const userInput = document.getElementById('user-input'); @@ -313,7 +313,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 2 (757) 622-7382'); ``` -When the `#user-input` element contains `0 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 0 (757) 622-7382`. +When the `#user-input` element contains `0 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 0 (757) 622-7382"`. ```js const userInput = document.getElementById('user-input'); @@ -326,7 +326,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 0 (757) 622-7382'); ``` -When the `#user-input` element contains `-1 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: -1 (757) 622-7382`. +When the `#user-input` element contains `-1 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: -1 (757) 622-7382"`. ```js const userInput = document.getElementById('user-input'); @@ -339,7 +339,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: -1 (757) 622-7382'); ``` -When the `#user-input` element contains `2 757 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2 757 622-7382`. +When the `#user-input` element contains `2 757 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2 757 622-7382"`. ```js const userInput = document.getElementById('user-input'); @@ -352,7 +352,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 2 757 622-7382'); ``` -When the `#user-input` element contains `10 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 10 (757) 622-7382`. +When the `#user-input` element contains `10 (757) 622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 10 (757) 622-7382"`. ```js const userInput = document.getElementById('user-input'); @@ -365,7 +365,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 10 (757) 622-7382'); ``` -When the `#user-input` element contains `27576227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 27576227382`. +When the `#user-input` element contains `27576227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 27576227382"`. ```js const userInput = document.getElementById('user-input'); @@ -378,7 +378,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 27576227382'); ``` -When the `#user-input` element contains `(275)76227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: (275)76227382`. +When the `#user-input` element contains `(275)76227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: (275)76227382"`. ```js const userInput = document.getElementById('user-input'); @@ -391,7 +391,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: (275)76227382'); ``` -When the `#user-input` element contains `2(757)6227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2(757)6227382`. +When the `#user-input` element contains `2(757)6227382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2(757)6227382"`. ```js const userInput = document.getElementById('user-input'); @@ -404,7 +404,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 2(757)6227382'); ``` -When the `#user-input` element contains `2(757)622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 2(757)622-7382`. +When the `#user-input` element contains `2(757)622-7382` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 2(757)622-7382"`. ```js const userInput = document.getElementById('user-input'); @@ -417,7 +417,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 2(757)622-7382'); ``` -When the `#user-input` element contains `555)-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 555)-555-5555`. +When the `#user-input` element contains `555)-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 555)-555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -430,7 +430,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 555)-555-5555'); ``` -When the `#user-input` element contains `(555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: (555-555-5555`. +When the `#user-input` element contains `(555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: (555-555-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -443,7 +443,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: (555-555-5555'); ``` -When `#user-input` contains `(555)5(55?)-5555` and `#check-btn` is clicked, `#results-div` should contain the text `Invalid US number: (555)5(55?)-5555`. +When `#user-input` contains `(555)5(55?)-5555` and `#check-btn` is clicked, `#results-div` should contain the text `"Invalid US number: (555)5(55?)-5555"`. ```js const userInput = document.getElementById('user-input'); @@ -456,7 +456,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: (555)5(55?)-5555'); ``` -When the `#user-input` element contains `55 55-55-555-5` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 55 55-55-555-5`. +When the `#user-input` element contains `55 55-55-555-5` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 55 55-55-555-5"`. ```js const userInput = document.getElementById('user-input'); @@ -469,7 +469,7 @@ checkBtn.click(); assert.strictEqual(resultsDiv.innerText.trim().toLowerCase(), 'invalid us number: 55 55-55-555-5'); ``` -When the `#user-input` element contains `11 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `Invalid US number: 11 555-555-5555`. +When the `#user-input` element contains `11 555-555-5555` and the `#check-btn` element is clicked, the `#results-div` element should contain the text `"Invalid US number: 11 555-555-5555"`. ```js const userInput = document.getElementById('user-input'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350854411ffb73feb6bb84e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350854411ffb73feb6bb84e.md index 4d75b5ff010..18f0138b44b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350854411ffb73feb6bb84e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350854411ffb73feb6bb84e.md @@ -22,7 +22,7 @@ Set the initial value of the accumulator to `0`. Your `reduce` method should have `0` as the initial value. ```js -assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el;\s*\}?\s*,\s*0\s*\)/) +assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085f80bd9b5429faa40c4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085f80bd9b5429faa40c4.md index 04b4aa83cff..8d803a3118d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085f80bd9b5429faa40c4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635085f80bd9b5429faa40c4.md @@ -28,13 +28,13 @@ assert.notMatch(getMean.toString(), /mean\s*=/); You should not change the logic within the `reduce` method. ```js -assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el;\s*\}?\s*,\s*0\s*\)/) +assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)/) ``` You should divide the result of the `reduce` method by the length of the array. ```js -assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el;\s*\}?\s*,\s*0\s*\)\s*\/\s*array\.length/) +assert.match(getMean.toString(), /(array\.reduce\(\s*\(\s*acc\s*,\s*el\s*\)\s*=>|array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{)\s*(return\s+)?\s*acc\s*\+\s*el\s*;?\s*\}?\s*,\s*0\s*\)\s*\/\s*array\.length/) ``` You should use implicit return syntax to directly return the result of `reduce` divided by the array length. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350866cce4c6d43bdf607c8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350866cce4c6d43bdf607c8.md index 823e573272a..043462ffd97 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350866cce4c6d43bdf607c8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6350866cce4c6d43bdf607c8.md @@ -20,7 +20,7 @@ assert.match(calculate.toString(), /mean\s*=/); Your `mean` variable should be assigned the value of `getMean(numbers)`. ```js -assert.match(calculate.toString(), /mean\s*=\s*getMean\(\s*numbers\s*\);/); +assert.match(calculate.toString(), /mean\s*=\s*getMean\(\s*numbers\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md index 83ea62fa0c9..10add7e4b05 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508750f040a348a440a0bf.md @@ -28,7 +28,7 @@ assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mean\1\s*\ Your `calculate` function should set the `#mean` element's `.textContent` to the value of `mean`. ```js -assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mean\1\s*\)\s*\.textContent\s*=\s*mean;/); +assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mean\1\s*\)\s*\.textContent\s*=\s*mean\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635089e3bd3e144f2db4094f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635089e3bd3e144f2db4094f.md index 60fccc709ec..4b92e6b0f3d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635089e3bd3e144f2db4094f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635089e3bd3e144f2db4094f.md @@ -16,7 +16,7 @@ To resolve this, add `return false;` after your `calculate();` call in the `onsu Your `onsubmit` attribute should have a `return false;` statement. ```js -assert.match(document.querySelector("form").getAttribute("onsubmit"), /return\s+false;/); +assert.match(document.querySelector("form").getAttribute("onsubmit"), /return\s+false\s*;?/); ``` Your `onsubmit` attribute should still call `calculate()`. @@ -28,7 +28,7 @@ assert.match(document.querySelector("form").getAttribute("onsubmit"), /calculate You should return `false` after you call `calculate()`. ```js -assert.match(document.querySelector("form").getAttribute("onsubmit"), /calculate\(\s*\);\s*return\s+false;/); +assert.match(document.querySelector("form").getAttribute("onsubmit"), /calculate\(\s*\)\s*;?\s*return\s+false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508bb4afb069534e81f33b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508bb4afb069534e81f33b.md index 32a5c5f07e6..ca740524ec8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508bb4afb069534e81f33b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/63508bb4afb069534e81f33b.md @@ -22,7 +22,7 @@ assert.match(getMedian.toString(), /sorted\s*=/); Your `getMedian` function should assign `array.sort()` to the `sorted` variable. ```js -assert.match(getMedian.toString(), /sorted\s*=\s*array\.sort\(\s*\);/); +assert.match(getMedian.toString(), /sorted\s*=\s*array\.sort\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635091f8dbf554575fb5aa0c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635091f8dbf554575fb5aa0c.md index d1f69fdbf79..83f73185e25 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635091f8dbf554575fb5aa0c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/635091f8dbf554575fb5aa0c.md @@ -16,7 +16,7 @@ Like the `getMean` function, you could condense this code into one line and redu Your `getMedian` function should return the value of `median`. ```js -assert.match(getMedian.toString(), /return\s+median;/); +assert.match(getMedian.toString(), /return\s+median\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352e93db104661305c5f658.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352e93db104661305c5f658.md index 9751409e235..9bf0aa85e91 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352e93db104661305c5f658.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352e93db104661305c5f658.md @@ -20,7 +20,7 @@ assert.match(getMode.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getMode.toString(), /counts\s*=\s*\{\s*\};/); +assert.match(getMode.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md index 76bb5162558..b092edbd557 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ea3a5b79e614ee2282fd.md @@ -36,7 +36,7 @@ assert.match(getMode.toString(), /if\s*\(\s*new\s+Set\s*\(\s*Object\.values\s*\( Your `if` statement should return `null` if the `size` property of the new `Set` is equal to `1`. ```js -assert.match(getMode.toString(), /if\s*\(\s*new\s+Set\s*\(\s*Object\.values\s*\(\s*counts\s*\)\s*\)\.size\s*===\s*1\s*\)\s*\{?\s*return\s+null;\s*\}?/); +assert.match(getMode.toString(), /if\s*\(\s*new\s+Set\s*\(\s*Object\.values\s*\(\s*counts\s*\)\s*\)\.size\s*===\s*1\s*\)\s*\{?\s*return\s+null\s*;?\s*\}?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ee566a59d31d24bde74b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ee566a59d31d24bde74b.md index 2964683fba8..be079a7a011 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ee566a59d31d24bde74b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352ee566a59d31d24bde74b.md @@ -28,7 +28,7 @@ assert.match(getMode.toString(), /return\s+mode\.join\(/) You should separate the elements of the `mode` array with a comma and a space. ```js -assert.match(getMode.toString(), /return\s+mode\.join\(\s*('|"),\s\1\s*\);/) +assert.match(getMode.toString(), /return\s+mode\.join\(\s*('|"),\s\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f09b1e53a420e7873344.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f09b1e53a420e7873344.md index 78a0941990f..48216e574c2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f09b1e53a420e7873344.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f09b1e53a420e7873344.md @@ -14,13 +14,13 @@ Add your `getMode()` function to your `calculate` logic, and update the respecti Your `calculate` function should have a `mode` variable with the value of `getMode(numbers)`. ```js -assert.match(calculate.toString(), /mode\s*=\s*getMode\(\s*numbers\s*\);/); +assert.match(calculate.toString(), /mode\s*=\s*getMode\(\s*numbers\s*\)\s*;?/); ``` Your `calculate` function should query the DOM for the `#mode` element and set the `textContent` to `mode`. ```js -assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mode\1\s*\)\.textContent\s*=\s*mode;/); +assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#mode\1\s*\)\.textContent\s*=\s*mode\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2526dccb523150b64fb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2526dccb523150b64fb.md index 62be62ebf63..6d68f26cb81 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2526dccb523150b64fb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2526dccb523150b64fb.md @@ -14,13 +14,13 @@ Add the logic for calculating and displaying the range to your `calculate` funct Your `calculate` function should set a `range` variable to the result of `getRange(numbers)`. ```js -assert.match(calculate.toString(), /range\s*=\s*getRange\(\s*numbers\s*\);/); +assert.match(calculate.toString(), /range\s*=\s*getRange\(\s*numbers\s*\)\s*;?/); ``` Your `calculate` function should set the `#range` element's `textContent` to the `range` variable. ```js -assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#range\1\s*\)\.textContent\s*=\s*range;/); +assert.match(calculate.toString(), /document\.querySelector\(\s*('|")#range\1\s*\)\.textContent\s*=\s*range\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2a24eb71b24284ca2b6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2a24eb71b24284ca2b6.md index 0f1e2c2a337..89cf7b2a2b4 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2a24eb71b24284ca2b6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352f2a24eb71b24284ca2b6.md @@ -34,7 +34,7 @@ assert.match(getVariance.toString(), /mean\s*=/); Your `mean` variable should be assigned the value of the `getMean` function, passing the `array` argument. ```js -assert.match(getVariance.toString(), /mean\s*=\s*getMean\(\s*array\s*\);/); +assert.match(getVariance.toString(), /mean\s*=\s*getMean\(\s*array\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352faf71a9db52631864634.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352faf71a9db52631864634.md index b21796dc2e8..5699cf665ce 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352faf71a9db52631864634.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352faf71a9db52631864634.md @@ -26,13 +26,13 @@ assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(/); Your `differences` variable should use the `el` parameter in the callback function. ```js -assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\s*\(?\s*el\s*\)?/); +assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\s*\(\s*el\s*\)/); ``` Your `map` callback should return the value of `el` minus `mean`. ```js -assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\s*\(?\s*el\s*\)?\s*\{\s*return\s+el\s*-\s*mean;?\s*\}/); +assert.match(getVariance.toString(), /differences\s*=\s*array\.map\(\s*function\s*\(\s*el\s*\)\s*\{\s*return\s+el\s*-\s*mean\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fbb93a91a8272f838d42.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fbb93a91a8272f838d42.md index 9190c16f086..a818e1625ae 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fbb93a91a8272f838d42.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fbb93a91a8272f838d42.md @@ -28,13 +28,13 @@ assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\ Your `squaredDifferences` variable should use the `el` parameter in the callback function. ```js -assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\(\s*function\s*\(?\s*el\s*\)?/); +assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\(\s*function\s*\(\s*el\s*\)/); ``` Your `map` callback should return the value of `el` squared. ```js -assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\(\s*function\s*\(?\s*el\s*\)?\s*\{\s*return\s+Math\.pow\(\s*el\s*,\s*2\s*\);\s*\}/); +assert.match(getVariance.toString(), /squaredDifferences\s*=\s*differences\.map\(\s*function\s*\(\s*el\s*\)\s*\{\s*return\s+Math\.pow\(\s*el\s*,\s*2\s*\)\s*;?\s*\}/); ``` Your `map` callback should use the `**` operator. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fcb156834128001ea945.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fcb156834128001ea945.md index 4ef5e9f65cc..d6976a21507 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fcb156834128001ea945.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fcb156834128001ea945.md @@ -34,7 +34,7 @@ assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDiffere Your `reduce` callback should return the sum of `acc` and `el`. ```js -assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*return\s*acc\s*\+\s*el\s*\;\s*\}\s*,\s*0\s*\)/); +assert.match(getVariance.toString(), /sumSquaredDifferences\s*=\s*squaredDifferences\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*return\s*acc\s*\+\s*el\s*;\s*\}\s*,\s*0\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fe473d53592a40ae403b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fe473d53592a40ae403b.md index f15f8ea3732..066f760c7b6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fe473d53592a40ae403b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fe473d53592a40ae403b.md @@ -32,19 +32,19 @@ assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\ Your `squared` variable should be set to the value of `difference` to the power of 2. ```js -assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);/); +assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?/); ``` Your `reduce` callback should return the value of `acc` plus `squared`. ```js -assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;/); +assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?\s*return\s+acc\s*\+\s*squared\s*;/); ``` You should not remove the initial value of `0` from your `.reduce()` method. ```js -assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)/); +assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fed209792d2b89e92ea1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fed209792d2b89e92ea1.md index ed853638976..e930dc58676 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fed209792d2b89e92ea1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6352fed209792d2b89e92ea1.md @@ -16,7 +16,7 @@ Divide your `.reduce()` call by the length of the array (in your `variance` decl You should divide the result of the `.reduce()` call by the length of the array. ```js -assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\);\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)\s*\/\s*array\.length;/); +assert.match(getVariance.toString(), /variance\s*=\s*array\.reduce\(\s*function\s*\(\s*acc\s*,\s*el\s*\)\s*\{\s*var\s+difference\s*=\s*el\s*-\s*mean\s*;\s*var\s+squared\s*=\s*Math\.pow\(\s*difference\s*,\s*2\s*\)\s*;?\s*return\s+acc\s*\+\s*squared\s*;\s*\}\s*,\s*0\s*\)\s*\/\s*array\.length\s*;?/); ``` You should return the value of `variance`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353024f5eab012fa2f57eec.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353024f5eab012fa2f57eec.md index ff6fb56f393..341d469b0fe 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353024f5eab012fa2f57eec.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353024f5eab012fa2f57eec.md @@ -16,7 +16,7 @@ Change your `standardDeviation` variable to use this method instead of `Math.pow Your `standardDeviation` variable should use `Math.sqrt()`. ```js -assert.match(getStandardDeviation.toString(), /standardDeviation\s*=\s*Math\.sqrt\(\s*variance\s*\);/); +assert.match(getStandardDeviation.toString(), /standardDeviation\s*=\s*Math\.sqrt\(\s*variance\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353028147d3c7309017216a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353028147d3c7309017216a.md index 3f15ec0b9e5..53516e8c7d5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353028147d3c7309017216a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-advanced-array-methods-by-building-a-statistics-calculator/6353028147d3c7309017216a.md @@ -14,7 +14,7 @@ Return your `standardDeviation` variable. Your `getStandardDeviation` function should return the `standardDeviation` variable. ```js -assert.match(getStandardDeviation.toString(), /return\s+standardDeviation;/); +assert.match(getStandardDeviation.toString(), /return\s+standardDeviation\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c14c8027369027334e802.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c14c8027369027334e802.md index d82695bdef8..076455b5569 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c14c8027369027334e802.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c14c8027369027334e802.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+data/); You should assign `await res.json()` to the `data` variable. ```js -assert.match(code, /\s*const\s+data\s*=\s*await\s+res\.json\(\s*\);?\s*/); +assert.match(code, /\s*const\s+data\s*=\s*await\s+res\.json\(\s*\)\s*;?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c337176a83407d0cd915c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c337176a83407d0cd915c.md index a0659e566a6..fe4fc8cf8a8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c337176a83407d0cd915c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c337176a83407d0cd915c.md @@ -28,7 +28,7 @@ assert.match(code, /\s*try\s*{[\s\S]*\s*console\.log\(\s*data\s*\)[\s\S]*}\s*cat You should call the `fetchData()` function, after the `fetchData()` function is defined. ```js -assert.match(code, /};?\s*fetchData\(\s*\)/); +assert.match(code, /}\s*;?\s*fetchData\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c359312d030093352fe41.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c359312d030093352fe41.md index 406f912900b..eb3b9848d35 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c359312d030093352fe41.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c359312d030093352fe41.md @@ -16,13 +16,13 @@ Start by creating an arrow function called `showLatestPosts`, which takes a sing You should have an arrow function called `showLatestPosts`. ```js -assert.match(code, /const\s+showLatestPosts\s*=\s*\(?\s*\w*\s*\)?\s*=>\s*/); +assert.match(code, /const\s+showLatestPosts\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*/); ``` Your `showLatestPosts` function should have a `data` parameter. ```js -assert.match(code, /showLatestPosts\s*=\s*\(?\s*data\s*\)?\s*=>/); +assert.match(code, /showLatestPosts\s*=\s*(\(\s*data\s*\)|data)\s*=>/); ``` `showLatestPosts` should be defined. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c565936a10109b3f59326.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c565936a10109b3f59326.md index 52b78f485e2..234b3eabeb2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c565936a10109b3f59326.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c565936a10109b3f59326.md @@ -16,13 +16,13 @@ Call the `showLatestPosts()` function at the end of your `try` block and pass in You should call `showLatestPosts()` at the end of your `try` block. ```js -assert.match(code, /\s*showLatestPosts\(.*\);??\s*/); +assert.match(code, /\s*showLatestPosts\(.*\)\s*;?\s*/); ``` You should pass `data` as the argument to `showLatestsPosts()`. ```js -assert.match(code, /\s*showLatestPosts\(\s*data\s*\);?\s*/); +assert.match(code, /\s*showLatestPosts\(\s*data\s*\)\s*;?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c8d9a73965c0a26d7f634.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c8d9a73965c0a26d7f634.md index 087f1f252e8..95a5c552f16 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c8d9a73965c0a26d7f634.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c8d9a73965c0a26d7f634.md @@ -16,7 +16,7 @@ Destructure the `topics` array from the `topic_list` object. You should use `const` to destructure the `topics` variable from the `topic_list` object. ```js -assert(code.match(/\s*const\s*\{\s*topics\s*\}\s*=\s*topic_list;?\s*/g)); +assert(code.match(/\s*const\s*\{\s*topics\s*\}\s*=\s*topic_list\s*;?\s*/g)); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c90830bbeb40ab15148a6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c90830bbeb40ab15148a6.md index a237a5f87c2..27b97e83e2e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c90830bbeb40ab15148a6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643c90830bbeb40ab15148a6.md @@ -24,19 +24,19 @@ assert.match(code, /topics\.map\(.*/); You should add a callback function to the `map()` method that has `item` for the parameter name. ```js -assert.match(code, /topics\.map\(\s*\(?\s*item\s*\)?\s*=>/g); +assert.match(code, /topics\.map\(\s*(\(\s*item\s*\)|item)\s*=>/g); ``` The body of the callback function should be empty. ```js -assert.match(code, /topics\.map\(\s*\(?\s*item\s*\)?\s*=>\s*{\s*}/g); +assert.match(code, /topics\.map\(\s*(\(\s*item\s*\)|item)\s*=>\s*{\s*}/g); ``` You should assign the result of the `map()` method to `postsContainer.innerHTML`. ```js -assert.match(code, /postsContainer\.innerHTML\s*=\s*topics\.map\(\s*\(?\s*item\s*\)?\s*=>\s*{\s*}/g); +assert.match(code, /postsContainer\.innerHTML\s*=\s*topics\.map\(\s*(\(\s*item\s*\)|item)\s*=>\s*{\s*}/g); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643ee973c162ae017b3d30db.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643ee973c162ae017b3d30db.md index 638cee03d51..8416683f46f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643ee973c162ae017b3d30db.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/643ee973c162ae017b3d30db.md @@ -16,7 +16,7 @@ Create a new arrow function called `timeAgo` with a parameter called `time`. You should have an arrow function named `timeAgo`. ```js -assert.match(code, /\s*const\s+timeAgo\s*=\s*\(?\s*.*\)?\s*=>/); +assert.match(code, /\s*const\s+timeAgo\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` `timeAgo` should be defined. @@ -34,13 +34,13 @@ assert.isFunction(timeAgo); `timeAgo` should be an empty function. ```js -assert.match(code, /\s*const\s+timeAgo\s*=\s*\(?\s*.*\)?\s*=>\s*{\s*}/); +assert.match(code, /\s*const\s+timeAgo\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}/); ``` You should have a `time` parameter for the `timeAgo` function. ```js -assert.match(code, /\s*const\s+timeAgo\s*=\s*\(?\s*time\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /\s*const\s+timeAgo\s*=\s*(\(\s*time\s*\)|time)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/64440a50d076c204051f2cc0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/64440a50d076c204051f2cc0.md index 7f5154d7ce4..3bffd3678e1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/64440a50d076c204051f2cc0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-asynchronous-programming-by-building-an-fcc-forum-leaderboard/64440a50d076c204051f2cc0.md @@ -16,7 +16,7 @@ Create an arrow function called `viewCount` with a parameter called `views`. You should have an arrow function named `viewCount`. ```js -assert.match(code, /const\s+viewCount\s*=\s*\(?[\s\S]*\)?\s*=>/); +assert.match(code, /const\s+viewCount\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` `viewCount` should be defined. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6407c6a2c2159309994779a5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6407c6a2c2159309994779a5.md index 3f565c661df..14477ffc95d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6407c6a2c2159309994779a5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6407c6a2c2159309994779a5.md @@ -20,7 +20,7 @@ assert.match(code, /array\.forEach\s*\(\s*\(\s*num\s*,\s*i\s*\)\s*=>\s*\{\s*cons You should use `innerText` to set the text of `outputValueNode` to `num`. ```js -assert.match(code, /array\.forEach\s*\(\s*\(\s*num\s*,\s*i\s*\)\s*=>\s*\{\s*const\s+outputValueNode\s*=\s*document\.getElementById\s*\(\s*`output-value-\$\{i\}`\s*\)\s*;?\s*outputValueNode\.innerText\s*=\s*num;?/) +assert.match(code, /array\.forEach\s*\(\s*\(\s*num\s*,\s*i\s*\)\s*=>\s*\{\s*const\s+outputValueNode\s*=\s*document\.getElementById\s*\(\s*`output-value-\$\{i\}`\s*\)\s*;?\s*outputValueNode\.innerText\s*=\s*num\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410e70c84bb660b4d2a5ea1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410e70c84bb660b4d2a5ea1.md index 36b213da469..4893e661e3b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410e70c84bb660b4d2a5ea1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410e70c84bb660b4d2a5ea1.md @@ -16,25 +16,25 @@ Create an `if` condition that checks if the current element is larger than the n You should not remove your `console.log` statement. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?/); ``` You should use an `if` statement in your nested loop. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(/); ``` Your `if` statement should check if the `array[j]` is larger than the `array[j+1]`. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)/); ``` Your `if` statement should be empty. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*}/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410edb33eeaf50dd9a22ab4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410edb33eeaf50dd9a22ab4.md index 81ad9316ddb..d34ab1e3c3c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410edb33eeaf50dd9a22ab4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410edb33eeaf50dd9a22ab4.md @@ -16,25 +16,25 @@ To do this, declare a `temp` variable and assign it the value of `array[j]`. The Within your `if` statement, you should declare a `temp` variable. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=/); ``` You should assign `temp` the value of `array[j]`. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?/); ``` You should assign `array[j]` the value of `array[j + 1]`. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?/); ``` You should assign `array[j + 1]` the value of `temp`. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410efff0ae97c0f06856511.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410efff0ae97c0f06856511.md index 96e3eafb555..b09a3bce3be 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410efff0ae97c0f06856511.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410efff0ae97c0f06856511.md @@ -14,7 +14,7 @@ Finally, after your outer loop has finished executing, return the sorted array. You should `return` the `array` variable. ```js -assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?\s*}\s*}\s*}\s*return\s+array;?\s*}/); +assert.match(code, /const\s+bubbleSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*for\s*\(\s*let\s+j\s*=\s*0\s*;\s*j\s*<\s*array\.length\s*-\s*1\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\s*\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*>\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*\)\s*{\s*const\s+temp\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*array\s*\[\s*j\s*\]\s*=\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*;?\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*temp\s*;?\s*}\s*}\s*}\s*return\s+array\s*;?\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410f149110ec60fd40fcfe1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410f149110ec60fd40fcfe1.md index 2eaede385a8..3a9c86ef6eb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410f149110ec60fd40fcfe1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410f149110ec60fd40fcfe1.md @@ -28,7 +28,7 @@ assert.isFunction(selectionSort); `selectionSort` should use arrow syntax. ```js -assert.match(code, /const\s+selectionSort\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+selectionSort\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` `selectionSort` should take a single `array` parameter. @@ -40,7 +40,7 @@ assert.match(code, /const\s+selectionSort\s*=\s*\(?\s*array/); `selectionSort` should be empty. ```js -assert.match(code, /const\s+selectionSort\s*=\s*\(?\s*array\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410fcd1f731fd17cdb101a7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410fcd1f731fd17cdb101a7.md index efe6fb18f3b..a51ab277352 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410fcd1f731fd17cdb101a7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6410fcd1f731fd17cdb101a7.md @@ -34,25 +34,25 @@ assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{ You should pass `array[minIndex]` as the third argument to `console.log()`. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?/); +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?/); ``` You should have an `if` statement after your `console.log()` call. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?\s*if\s*\(?/); +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(?/); ``` You should have a condition in your `if` statement that checks if `array[j]` is less than `array[minIndex]`. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{?/); +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{?/); ``` Your `if` statement should set `minIndex` to `j`. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}/); +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411024727181d190ef03166.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411024727181d190ef03166.md index 810622c0129..0ae34cae54e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411024727181d190ef03166.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411024727181d190ef03166.md @@ -16,25 +16,25 @@ Like you did in your bubble sort, use a `temp` variable to extract the value at After your nested `for` loop, you should declare a `temp` variable. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=/); +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=/); ``` You should assign `array[i]` to `temp`. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]/) +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]/) ``` You should assign `array[minIndex]` to `array[i]`. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]/) +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]/) ``` You should assign `temp` to `array[minIndex]`. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}/) +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110727cefd3d1d9bdb0128.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110727cefd3d1d9bdb0128.md index 592955fb781..dc7da4ec50a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110727cefd3d1d9bdb0128.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110727cefd3d1d9bdb0128.md @@ -14,7 +14,7 @@ Finally, after your outer loop has finished, you need to return the array. Once You should `return` the `array` after your outer loop completes. ```js -assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\);\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}\s*return\s+array;?\s*/) +assert.match(code, /const\s+selectionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*0\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*let\s+minIndex\s*=\s*i\s*;?\s*for\s*\(\s*let\s+j\s*=\s*i\s*\+\s*1\s*;\s*j\s*<\s*array\.length\s*;\s*j\s*\+\+\s*\)\s*{\s*console\.log\(\s*array\s*,\s*array\s*\[\s*j\s*\]\s*,\s*array\s*\[\s*minIndex\s*\]\s*\)\s*;?\s*if\s*\(\s*array\s*\[\s*j\s*\]\s*<\s*array\s*\[\s*minIndex\s*\]\s*\)\s*{\s*minIndex\s*=\s*j\s*;?\s*}\s*}\s*const\s+temp\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*array\s*\[\s*i\s*\]\s*=\s*array\s*\[\s*minIndex\s*\]\s*;?\s*array\s*\[\s*minIndex\s*\]\s*=\s*temp\s*;?\s*}\s*return\s+array\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110998bc00321fd8052ab5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110998bc00321fd8052ab5.md index fb3f006b828..d4853a0281b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110998bc00321fd8052ab5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64110998bc00321fd8052ab5.md @@ -28,7 +28,7 @@ assert.isFunction(insertionSort); `insertionSort` should use arrow syntax. ```js -assert.match(code, /const\s+insertionSort\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+insertionSort\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` `insertionSort` should take a single `array` parameter. @@ -40,7 +40,7 @@ assert.match(code, /const\s+insertionSort\s*=\s*\(?\s*array/); `insertionSort` should be empty. ```js -assert.match(code, /const\s+insertionSort\s*=\s*\(?\s*array\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641110e4fb696b259dbf0bcf.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641110e4fb696b259dbf0bcf.md index 9a850eb65b2..5bdc431dc8f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641110e4fb696b259dbf0bcf.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641110e4fb696b259dbf0bcf.md @@ -43,7 +43,7 @@ assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{ Your `while` loop should decrement `j` inside the loop. ```js -assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*j--;?\s*\}/); +assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*j--\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411135e9ee2fa26c882eb02.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411135e9ee2fa26c882eb02.md index 10beeeffc99..4acb6606bbb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411135e9ee2fa26c882eb02.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/6411135e9ee2fa26c882eb02.md @@ -16,7 +16,7 @@ Do so by assigning the value at the `j` index to the next index. Before decrementing `j`, assign the value at `j` to the index `j + 1`. ```js -assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--;?\s*\}/); +assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112c9cf53d632910ea2f9b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112c9cf53d632910ea2f9b.md index 176bc466aea..636d833956a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112c9cf53d632910ea2f9b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112c9cf53d632910ea2f9b.md @@ -16,7 +16,7 @@ Use the assignment operator to insert your current value into the correct index. You should assign `currValue` to the index `j + 1`. ```js -assert.match(code, /const\s+insertionSort\s*=\s*\(\s*array\s*\)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue;?/); +assert.match(code, /const\s+insertionSort\s*=\s*\(\s*array\s*\)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--\s*;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112cea9e6ac22a314628b0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112cea9e6ac22a314628b0.md index bc7228c8c09..3ec11eb2204 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112cea9e6ac22a314628b0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64112cea9e6ac22a314628b0.md @@ -14,7 +14,7 @@ After your `for` loop has finished, you need to return the array. You should the You should `return` the `array`. ```js -assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue;?\s*\}\s*return\s+array;?\s*\}/); +assert.match(code, /const\s+insertionSort\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*{\s*for\s*\(\s*let\s+i\s*=\s*1\s*;\s*i\s*<\s*array\.length\s*;\s*i\s*\+\+\s*\)\s*{\s*const\s+currValue\s*=\s*array\s*\[\s*i\s*\]\s*;?\s*let\s+j\s*=\s*i\s*-\s*1\s*;?\s*while\s*\(\s*j\s*>=\s*0\s*&&\s*array\s*\[\s*j\s*\]\s*>\s*currValue\s*\)\s*{\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*array\s*\[\s*j\s*\]\s*;?\s*j--\s*;?\s*\}\s*array\s*\[\s*j\s*\+\s*1\s*\]\s*=\s*currValue\s*;?\s*\}\s*return\s+array\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641130423e5f512d8972dae1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641130423e5f512d8972dae1.md index 939646d4282..727d77ebcbc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641130423e5f512d8972dae1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/641130423e5f512d8972dae1.md @@ -16,7 +16,7 @@ To fix this, you can pass a callback function to the `.sort()` method. The callb You should pass a callback function to the `.sort()` method. Remember to use arrow syntax. ```js -assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` The callback function should have two parameters, `a` and `b`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64113124efd2852edafaf25f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64113124efd2852edafaf25f.md index 5cad2b15bc9..23e0148b620 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64113124efd2852edafaf25f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-algorithmic-thinking-by-building-a-number-sorter/64113124efd2852edafaf25f.md @@ -26,7 +26,7 @@ assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\( Your callback function should return `a - b`. ```js -assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*{\s*return\s+a\s*-\s*b;?\s*}\s*\)/); +assert.match(code, /const\s+sortedValues\s*=\s*inputValues\s*\.\s*sort\s*\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*{\s*return\s+a\s*-\s*b\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b3eab50e193608c19fc6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b3eab50e193608c19fc6.md index 79386d081b8..c189dd0c01b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b3eab50e193608c19fc6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b3eab50e193608c19fc6.md @@ -26,7 +26,7 @@ assert.isUndefined(fighting); You should not assign a value to your `fighting` variable. Don't forget the semi-colon at the end of the line. ```js -assert.match(code, /let\s+fighting;/); +assert.match(code, /let\s+fighting\s*;/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b41c9494f937560640ab.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b41c9494f937560640ab.md index 52dce20cab4..f531177315f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b41c9494f937560640ab.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3b41c9494f937560640ab.md @@ -32,7 +32,7 @@ assert.isUndefined(monsterHealth); You should not assign a value to your `monsterHealth` variable. Remember your semi-colon. ```js -assert.match(code, /let\s+monsterHealth;/); +assert.match(code, /let\s+monsterHealth\s*;/); ``` You should use `let` to declare your `inventory` variable. @@ -50,7 +50,7 @@ assert.isUndefined(inventory); You should not assign a value to your `inventory` variable. Remember your semi-colon. ```js -assert.match(code, /let\s+inventory;/); +assert.match(code, /let\s+inventory\s*;/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3c8bf3980c14c438d2aed.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3c8bf3980c14c438d2aed.md index 9c0d4012a26..a04ab0840e3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3c8bf3980c14c438d2aed.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a3c8bf3980c14c438d2aed.md @@ -20,13 +20,13 @@ function functionName() { You should have a `console.log("Going to store.");` line in your code. Don't forget the semi-colon. ```js -assert.match(code, /console\.log\(\s*('|")Going to store\.\1\s*\);/); +assert.match(code, /console\.log\(\s*('|")Going to store\.\1\s*\)\s*;/); ``` Your `console.log("Going to store.");` line should be in your `goStore` function. ```js -assert.match(goStore.toString(), /console\.log\(\s*('|")Going to store\.\1\s*\);/); +assert.match(goStore.toString(), /console\.log\(\s*('|")Going to store\.\1\s*\)\s*;/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8a929e4260d08093756d2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8a929e4260d08093756d2.md index 8483df88bb8..3f8f81b94ae 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8a929e4260d08093756d2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8a929e4260d08093756d2.md @@ -7,7 +7,9 @@ dashedName: step-51 # --description-- -Create a variable called `locations` and set it to an empty array. +In your role playing game, you will be able to visit different locations like the **store**, the **cave**, and the **town square**. You will need to create a data structure that will hold the different locations. + +Use `const` to create a variable called `locations` and assign it an empty array. # --hints-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b1762b7775124622e1a3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b1762b7775124622e1a3.md index 3fecc2a0238..7c1bc535b36 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b1762b7775124622e1a3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b1762b7775124622e1a3.md @@ -26,7 +26,7 @@ assert.match(goTown.toString(), /update\(\s*\)/); Don't forget your ending semi-colon. ```js -assert.match(goTown.toString(), /update\(\s*\);/); +assert.match(goTown.toString(), /update\(\s*\)\s*;/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b3cc436db8139cc5fc09.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b3cc436db8139cc5fc09.md index e53b6ea71e6..f7456fbe987 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b3cc436db8139cc5fc09.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b3cc436db8139cc5fc09.md @@ -20,7 +20,7 @@ myFunction(arg) يجب أن تبعث القائمة `locations` ألى `update` عند تفعيلها. ```js -assert.match(goTown.toString(), /update\(\s*locations\s*\);/); +assert.match(goTown.toString(), /update\(\s*locations\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b6536156c51500739b41.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b6536156c51500739b41.md index b1510540a56..1405e2bf086 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b6536156c51500739b41.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8b6536156c51500739b41.md @@ -30,13 +30,13 @@ assert.match(code, /locations\s*\[\s*0\s*\]/); You should pass the first object in the `locations` array into the `update` function. ```js -assert.match(code, /update\(\s*locations\s*\[\s*0\s*\]\s*\);/); +assert.match(code, /update\(\s*locations\s*\[\s*0\s*\]\s*\)\s*;?/); ``` This call should still be in your `goTown()` function. ```js -assert.match(goTown.toString(), /update\(\s*locations\s*\[\s*0\s*\]\s*\);/); +assert.match(goTown.toString(), /update\(\s*locations\s*\[\s*0\s*\]\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8c4db0710f3260f867a92.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8c4db0710f3260f867a92.md index bd39c41b2b3..716c07d07c9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8c4db0710f3260f867a92.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8c4db0710f3260f867a92.md @@ -39,7 +39,7 @@ assert.match(buyHealth.toString(), /if\s*\(\s*gold\s*>=\s*10\s*\)/); All of your `buyHealth` code should be inside the `if` statement. ```js -assert.match(buyHealth.toString(), /if\s*\(\s*gold\s*>=\s*10\s*\)\s*{\s*gold\s*-=\s*10;\s*health\s*\+=\s*10;\s*goldText\.innerText\s*=\s*gold;\s*healthText\.innerText\s*=\s*health;\s*}/); +assert.match(buyHealth.toString(), /if\s*\(\s*gold\s*>=\s*10\s*\)\s*{\s*gold\s*-=\s*10\s*;?\s*health\s*\+=\s*10\s*;?\s*goldText\.innerText\s*=\s*gold\s*;?\s*healthText\.innerText\s*=\s*health\s*;?\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8cbd1e3595431d5a2b3f1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8cbd1e3595431d5a2b3f1.md index 6e9dae71c36..69600f23d68 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8cbd1e3595431d5a2b3f1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8cbd1e3595431d5a2b3f1.md @@ -26,7 +26,7 @@ assert.match(code, /let\s+newWeapon/); `newWeapon` should be initialised to have the value of `weapons`. Don't forget your semi-colon. ```js -assert.match(buyWeapon.toString(), /newWeapon\s*=\s*weapons;/); +assert.match(buyWeapon.toString(), /newWeapon\s*=\s*weapons\s*;/); ``` `newWeapon` should be declared before you modify `text`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8d24c97461b3ddb9397c8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8d24c97461b3ddb9397c8.md index 8adbb83ea32..b332d3a1e86 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8d24c97461b3ddb9397c8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8d24c97461b3ddb9397c8.md @@ -22,7 +22,7 @@ assert.match(buyWeapon.toString(), /button2\.innerText/); You should set the value of `button2.innerText` to `"Sell weapon for 15 gold"`. ```js -assert.match(buyWeapon.toString(), /button2\.innerText\s*=\s*('|")Sell weapon for 15 gold\1;/); +assert.match(buyWeapon.toString(), /button2\.innerText\s*=\s*('|")Sell weapon for 15 gold\1\s*;?/); ``` You should set the value of `button2.onclick`. @@ -34,7 +34,7 @@ assert.match(buyWeapon.toString(), /button2\.onclick/); You should set the value of `button2.onclick` to `sellWeapon`. ```js -assert.match(buyWeapon.toString(), /button2\.onclick\s*=\s*sellWeapon;/); +assert.match(buyWeapon.toString(), /button2\.onclick\s*=\s*sellWeapon\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dd9cdb16324b04cfd958.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dd9cdb16324b04cfd958.md index f2a071ee77d..a9f9c13099b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dd9cdb16324b04cfd958.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dd9cdb16324b04cfd958.md @@ -16,7 +16,7 @@ On the next line, call the `goFight` function. You should set `fighting` equal to `0`. ```js -assert.match(fightSlime.toString(), /fighting\s*=\s*0;/); +assert.match(fightSlime.toString(), /fighting\s*=\s*0\s*;?/); ``` لا يجب عليك استخدام `let` أو `const`. @@ -28,7 +28,7 @@ assert.notMatch(fightSlime.toString(), /let|const/); You should call the `goFight` function. ```js -assert.match(fightSlime.toString(), /goFight\(\s*\);/); +assert.match(fightSlime.toString(), /goFight\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dfcf7fb1044d2f478fd1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dfcf7fb1044d2f478fd1.md index dff775b563a..726c76a42e1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dfcf7fb1044d2f478fd1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62a8dfcf7fb1044d2f478fd1.md @@ -14,13 +14,13 @@ Following the same pattern as the `fightSlime` function, use that code in the `f You should set `fighting` to `1` in your `fightBeast` function. ```js -assert.match(fightBeast.toString(), /fighting\s*=\s*1;/); +assert.match(fightBeast.toString(), /fighting\s*=\s*1\s*;?/); ``` You should set `fighting` to `2` in your `fightDragon` function. ```js -assert.match(fightDragon.toString(), /fighting\s*=\s*2;/); +assert.match(fightDragon.toString(), /fighting\s*=\s*2\s*;?/); ``` You should remove the `console.log` from your `fightDragon` function. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa1eec891ed731db227a36.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa1eec891ed731db227a36.md index a3ad193f983..184f03a6d71 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa1eec891ed731db227a36.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa1eec891ed731db227a36.md @@ -22,7 +22,7 @@ if (score > 0) { } // ternary operator -score > 0 ? score : default_score +return score > 0 ? score : default_score ``` In `getMonsterAttackValue`, change `return hit` to a ternary operator that returns `hit` if `hit` is greater than `0`, or returns `0` if it is not. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa20e9cf1be9358f5aceae.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa20e9cf1be9358f5aceae.md index 0f1429cf2ad..695120612df 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa20e9cf1be9358f5aceae.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa20e9cf1be9358f5aceae.md @@ -14,13 +14,13 @@ Add an `else` statement to the first `if` statement inside your `attack()` funct You should add an `else` block after your `if (isMonsterHit())` block. ```js -assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1;\s*\}\s*else/) +assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1\s*;?\s*\}\s*else/) ``` You should add the text `" You miss."` to the end of `text.innerText`. Remember to use compound assignment and make sure there is a space before the word `You`. ```js -assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1;\s*\}\s*else\s*\{\s*text\.innerText\s*\+=\s*('|")\sYou miss\.\1/) +assert.match(attack.toString(), /if\s*\(\s*isMonsterHit\(\s*\)\s*\)\s*\{\s*monsterHealth\s*-=\s*weapons\s*\[\s*currentWeapon\s*\]\s*\.power\s*\+\s*Math\.floor\(\s*Math\.random\(\s*\)\s*\*\s*xp\s*\)\s*\+\s*1\s*;?\s*\}\s*else\s*\{\s*text\.innerText\s*\+=\s*('|")\sYou miss\.\1/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa22aba186563bcbf2c395.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa22aba186563bcbf2c395.md index cb4f98370a3..9fe78ac8511 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa22aba186563bcbf2c395.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62aa22aba186563bcbf2c395.md @@ -28,7 +28,7 @@ assert.match(attack.toString(), /--/); You should decrement `currentWeapon` in your `if` statement. ```js -assert.match(attack.toString(), /(currentWeapon\s*--;?\s*}\s*})$/); +assert.match(attack.toString(), /(currentWeapon\s*--\s*;?\s*}\s*})$/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62ba17beef16c563069a65d8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62ba17beef16c563069a65d8.md index f3d11a95837..ed0219f82b8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62ba17beef16c563069a65d8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-javascript-by-building-a-role-playing-game/62ba17beef16c563069a65d8.md @@ -9,6 +9,8 @@ dashedName: step-136 In the `locations` array, add another object at the end. Set the `name` property to `"lose"`, set `"button text"` to an array with three `"REPLAY?"` strings, set `"button functions"` to an array with three `restart` variables, and set `text` to `"You die. ☠"`. +In a later step, you will update the code for the `☠` emoticon text to properly display on the page. + # --hints-- You should have six values in the `locations` array. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3287b182ec0efe8a3135.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3287b182ec0efe8a3135.md index 6bfda70bfa3..59e2d1ffb9c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3287b182ec0efe8a3135.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3287b182ec0efe8a3135.md @@ -9,19 +9,19 @@ dashedName: step-7 Following that same data structure, add the products from this table (in order) to your `products` array. Increment the `id` for each product, counting up. -| `name` | `price` | `category` | -| ------------------------------ | ------- | ----------- | -| `French Macaroon` | `3.99` | `Macaroon` | -| `Pumpkin Cupcake` | `3.99` | `Cupcake` | -| `Chocolate Cupcake` | `5.99` | `Cupcake` | -| `Chocolate Pretzels (4 Pack)` | `10.99` | `Pretzel` | -| `Strawberry Ice Cream` | `2.99` | `Ice Cream` | -| `Chocolate Macaroons (4 Pack)` | `9.99` | `Macaroon` | -| `Strawberry Pretzel` | `4.99` | `Pretzel` | -| `Butter Pecan Ice Cream` | `2.99` | `Ice Cream` | -| `Rocky Road Ice Cream` | `2.99` | `Ice Cream` | -| `Vanilla Macaroons (5 Pack)` | `11.99` | `Macaroon` | -| `Lemon Cupcakes (4 Pack)` | `12.99` | `Cupcake` | +| `name` | `price` | `category` | +| ----------------------------- | ------- | ----------- | +| `French Macaron` | `3.99` | `Macaron` | +| `Pumpkin Cupcake` | `3.99` | `Cupcake` | +| `Chocolate Cupcake` | `5.99` | `Cupcake` | +| `Chocolate Pretzels (4 Pack)` | `10.99` | `Pretzel` | +| `Strawberry Ice Cream` | `2.99` | `Ice Cream` | +| `Chocolate Macarons (4 Pack)` | `9.99` | `Macaron` | +| `Strawberry Pretzel` | `4.99` | `Pretzel` | +| `Butter Pecan Ice Cream` | `2.99` | `Ice Cream` | +| `Rocky Road Ice Cream` | `2.99` | `Ice Cream` | +| `Vanilla Macarons (5 Pack)` | `11.99` | `Macaron` | +| `Lemon Cupcakes (4 Pack)` | `12.99` | `Cupcake` | # --hints-- @@ -31,10 +31,10 @@ Your second object in the `products` array should have an `id` property set to t assert.equal(products[1].id, 2); ``` -Your second object in the `products` array should have a `name` property set to `French Macaroon`. +Your second object in the `products` array should have a `name` property set to `French Macaron`. ```js -assert.equal(products[1].name, 'French Macaroon'); +assert.equal(products[1].name, 'French Macaron'); ``` Your second object in the `products` array should have a `price` property set to the number `3.99`. @@ -43,10 +43,10 @@ Your second object in the `products` array should have a `price` property set to assert.equal(products[1].price, 3.99); ``` -Your second object in the `products` array should have a `category` property set to `Macaroon`. +Your second object in the `products` array should have a `category` property set to `Macaron`. ```js -assert.equal(products[1].category, 'Macaroon'); +assert.equal(products[1].category, 'Macaron'); ``` Your third object in the `products` array should have an `id` property set to the number `3`. @@ -151,10 +151,10 @@ Your seventh object in the `products` array should have an `id` property set to assert.equal(products[6].id, 7); ``` -Your seventh object in the `products` array should have a `name` property set to `Chocolate Macaroons (4 Pack)`. +Your seventh object in the `products` array should have a `name` property set to `Chocolate Macarons (4 Pack)`. ```js -assert.equal(products[6].name, 'Chocolate Macaroons (4 Pack)'); +assert.equal(products[6].name, 'Chocolate Macarons (4 Pack)'); ``` Your seventh object in the `products` array should have a `price` property set to the number `9.99`. @@ -163,10 +163,10 @@ Your seventh object in the `products` array should have a `price` property set t assert.equal(products[6].price, 9.99); ``` -Your seventh object in the `products` array should have a `category` property set to `Macaroon`. +Your seventh object in the `products` array should have a `category` property set to `Macaron`. ```js -assert.equal(products[6].category, 'Macaroon'); +assert.equal(products[6].category, 'Macaron'); ``` Your eighth object in the `products` array should have an `id` property set to the number `8`. @@ -247,10 +247,10 @@ Your eleventh object in the `products` array should have an `id` property set to assert.equal(products[10].id, 11); ``` -Your eleventh object in the `products` array should have a `name` property set to `Vanilla Macaroons (5 Pack)`. +Your eleventh object in the `products` array should have a `name` property set to `Vanilla Macarons (5 Pack)`. ```js -assert.equal(products[10].name, 'Vanilla Macaroons (5 Pack)'); +assert.equal(products[10].name, 'Vanilla Macarons (5 Pack)'); ``` Your eleventh object in the `products` array should have a `price` property set to the number `11.99`. @@ -259,10 +259,10 @@ Your eleventh object in the `products` array should have a `price` property set assert.equal(products[10].price, 11.99); ``` -Your eleventh object in the `products` array should have a `category` property set to `Macaroon`. +Your eleventh object in the `products` array should have a `category` property set to `Macaron`. ```js -assert.equal(products[10].category, 'Macaroon'); +assert.equal(products[10].category, 'Macaron'); ``` Your twelfth object in the `products` array should have an `id` property set to the number `12`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3427fc3e9214c9ed2a14.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3427fc3e9214c9ed2a14.md index e927e0dd6b4..b7604a68b9b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3427fc3e9214c9ed2a14.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec3427fc3e9214c9ed2a14.md @@ -209,9 +209,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -239,9 +239,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -263,9 +263,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec36f6133df7160be3ec66.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec36f6133df7160be3ec66.md index 8b6436e5fde..22ad419d8cb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec36f6133df7160be3ec66.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec36f6133df7160be3ec66.md @@ -203,9 +203,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -233,9 +233,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -257,9 +257,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec47b454495519739486a7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec47b454495519739486a7.md index 00dff2ec806..e34598c3f7b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec47b454495519739486a7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ec47b454495519739486a7.md @@ -207,9 +207,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -237,9 +237,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -261,9 +261,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d38a5d29d0696f8d820.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d38a5d29d0696f8d820.md index 20cc3554295..97964b35493 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d38a5d29d0696f8d820.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d38a5d29d0696f8d820.md @@ -219,9 +219,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -249,9 +249,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -273,9 +273,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d8f9e7168076e932fe2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d8f9e7168076e932fe2.md index dce4ad76d9f..c07a1d84aae 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d8f9e7168076e932fe2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5d8f9e7168076e932fe2.md @@ -228,9 +228,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -258,9 +258,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -282,9 +282,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5e0f08e82208364c4128.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5e0f08e82208364c4128.md index 98d8be81782..52638fc1cd5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5e0f08e82208364c4128.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5e0f08e82208364c4128.md @@ -221,9 +221,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -251,9 +251,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -275,9 +275,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5ea8be892e0955ab346c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5ea8be892e0955ab346c.md index ff8f20c7553..12ac72cedb7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5ea8be892e0955ab346c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5ea8be892e0955ab346c.md @@ -215,9 +215,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -245,9 +245,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -269,9 +269,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5fc113bcb20a5db9214b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5fc113bcb20a5db9214b.md index 6b5d79e28d8..489a418c121 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5fc113bcb20a5db9214b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee5fc113bcb20a5db9214b.md @@ -210,9 +210,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -240,9 +240,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -264,9 +264,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee611d478dca0b77f6a393.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee611d478dca0b77f6a393.md index 634103b2f56..70ebee87ac8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee611d478dca0b77f6a393.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee611d478dca0b77f6a393.md @@ -224,9 +224,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -254,9 +254,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -278,9 +278,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee7c664f9b65137d925c8a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee7c664f9b65137d925c8a.md index ea939f5de7c..bb57984a505 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee7c664f9b65137d925c8a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63ee7c664f9b65137d925c8a.md @@ -225,9 +225,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -255,9 +255,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -279,9 +279,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea5cea403a81a68ae493c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea5cea403a81a68ae493c.md index 83a56778bac..c2ff741e2f7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea5cea403a81a68ae493c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea5cea403a81a68ae493c.md @@ -233,9 +233,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -263,9 +263,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -287,9 +287,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea817673c8e1c22927fa6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea817673c8e1c22927fa6.md index 3d3f075bb94..bbaf6e2a4d8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea817673c8e1c22927fa6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea817673c8e1c22927fa6.md @@ -29,7 +29,7 @@ You should use destructuring to get the `name` and `price` variables from `produ ```js const afterAdd = code.split("addItem")[1]; -assert.match(afterAdd, /const\s*\{\s*name\s*,\s*price\s*\}\s*=\s*product;?\b/); +assert.match(afterAdd, /const\s*\{\s*name\s*,\s*price\s*\}\s*=\s*product\s*;?\b/); ``` # --seed-- @@ -210,9 +210,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -240,9 +240,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -264,9 +264,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea8e1e143ae1d098c8c9d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea8e1e143ae1d098c8c9d.md index fa82700d4db..e6a97bdb41b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea8e1e143ae1d098c8c9d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eea8e1e143ae1d098c8c9d.md @@ -211,9 +211,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -241,9 +241,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -265,9 +265,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eeb8e86becbf1e75c2cb0d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eeb8e86becbf1e75c2cb0d.md index 4bd94a3e4cb..5617ab039cd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eeb8e86becbf1e75c2cb0d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eeb8e86becbf1e75c2cb0d.md @@ -210,9 +210,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -240,9 +240,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -264,9 +264,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eedebb0ec0231ff1cede1a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eedebb0ec0231ff1cede1a.md index 4a1199f5319..bb3cf99b20f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eedebb0ec0231ff1cede1a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eedebb0ec0231ff1cede1a.md @@ -224,9 +224,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -254,9 +254,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -278,9 +278,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efdbc22a0c56070beabed7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efdbc22a0c56070beabed7.md index 8b264bf50e8..ae9ce28fdaa 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efdbc22a0c56070beabed7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efdbc22a0c56070beabed7.md @@ -218,9 +218,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -248,9 +248,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -272,9 +272,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efe370bbfc4a08d500118e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efe370bbfc4a08d500118e.md index f210ff3bb8f..5835ba475be 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efe370bbfc4a08d500118e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63efe370bbfc4a08d500118e.md @@ -219,9 +219,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -249,9 +249,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -273,9 +273,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff02f00e69a0b2ac10b43.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff02f00e69a0b2ac10b43.md index 8cac93ce139..f15180772d0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff02f00e69a0b2ac10b43.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff02f00e69a0b2ac10b43.md @@ -210,9 +210,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -240,9 +240,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -264,9 +264,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff98ffb1d5a0d24ec79cb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff98ffb1d5a0d24ec79cb.md index e44e6278d67..65ed7012486 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff98ffb1d5a0d24ec79cb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63eff98ffb1d5a0d24ec79cb.md @@ -228,9 +228,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -258,9 +258,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -282,9 +282,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63effe558c87a70e7072e447.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63effe558c87a70e7072e447.md index 25a5a35744f..a4e51d016f6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63effe558c87a70e7072e447.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63effe558c87a70e7072e447.md @@ -217,9 +217,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -247,9 +247,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -271,9 +271,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0165121a9181342d5bc66.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0165121a9181342d5bc66.md index e7afead9faf..b557e4ecb5c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0165121a9181342d5bc66.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0165121a9181342d5bc66.md @@ -210,9 +210,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -240,9 +240,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -264,9 +264,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f017b4ad028a148eb713c0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f017b4ad028a148eb713c0.md index a79180e0575..90dcc4d9558 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f017b4ad028a148eb713c0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f017b4ad028a148eb713c0.md @@ -233,9 +233,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -263,9 +263,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -287,9 +287,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01861f813e01564c95315.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01861f813e01564c95315.md index f66e503a1ff..1156fffc819 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01861f813e01564c95315.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01861f813e01564c95315.md @@ -209,9 +209,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -239,9 +239,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -263,9 +263,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f018f04e487e164dc27bd9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f018f04e487e164dc27bd9.md index 5cb548f49a3..e8de5477aff 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f018f04e487e164dc27bd9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f018f04e487e164dc27bd9.md @@ -230,9 +230,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -260,9 +260,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -284,9 +284,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01c9791a0aa1751c73760.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01c9791a0aa1751c73760.md index ab13f1b4fed..c40e227d6bc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01c9791a0aa1751c73760.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f01c9791a0aa1751c73760.md @@ -213,9 +213,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -243,9 +243,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -267,9 +267,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0224ceb16dc196d2c860a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0224ceb16dc196d2c860a.md index ccf7e7094d1..26b6cc40e8e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0224ceb16dc196d2c860a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0224ceb16dc196d2c860a.md @@ -213,9 +213,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -243,9 +243,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -267,9 +267,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f026d041bc6c1a3d5cba0f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f026d041bc6c1a3d5cba0f.md index b72606b613e..8ce84fd719d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f026d041bc6c1a3d5cba0f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f026d041bc6c1a3d5cba0f.md @@ -215,9 +215,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -245,9 +245,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -269,9 +269,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0284532742c1b26c7a052.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0284532742c1b26c7a052.md index 82367d1abda..f3b6ec79c68 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0284532742c1b26c7a052.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0284532742c1b26c7a052.md @@ -213,9 +213,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -243,9 +243,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -267,9 +267,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0289df84a581bbdbd29b7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0289df84a581bbdbd29b7.md index c255629475c..1be506d69c9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0289df84a581bbdbd29b7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0289df84a581bbdbd29b7.md @@ -209,9 +209,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -239,9 +239,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -263,9 +263,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0295e673b661ccb299e8a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0295e673b661ccb299e8a.md index 5d7b6016bc7..49d6a002011 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0295e673b661ccb299e8a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0295e673b661ccb299e8a.md @@ -212,9 +212,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -242,9 +242,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -266,9 +266,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f029b96b9e9e1df93be951.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f029b96b9e9e1df93be951.md index 1cadbded19d..72e80b6eec3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f029b96b9e9e1df93be951.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f029b96b9e9e1df93be951.md @@ -201,9 +201,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -231,9 +231,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -255,9 +255,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02a4ef92d711ec1ff618c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02a4ef92d711ec1ff618c.md index d4206e295e8..aa8d6d99792 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02a4ef92d711ec1ff618c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02a4ef92d711ec1ff618c.md @@ -234,9 +234,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -264,9 +264,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -288,9 +288,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02b22cce1c11fe9604381.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02b22cce1c11fe9604381.md index 254df0047b0..024bc52e90c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02b22cce1c11fe9604381.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02b22cce1c11fe9604381.md @@ -201,9 +201,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -231,9 +231,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -255,9 +255,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02bdeb9b428208b97eb6b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02bdeb9b428208b97eb6b.md index eff305ad7e9..fa1e4fa971c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02bdeb9b428208b97eb6b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02bdeb9b428208b97eb6b.md @@ -218,9 +218,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -248,9 +248,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -272,9 +272,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02c6e18773921ba50aa53.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02c6e18773921ba50aa53.md index 6240db91d1b..f3014956159 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02c6e18773921ba50aa53.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f02c6e18773921ba50aa53.md @@ -212,9 +212,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -242,9 +242,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -266,9 +266,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0311f5ea9382388d6124f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0311f5ea9382388d6124f.md index be31f3990e4..44018f0dc89 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0311f5ea9382388d6124f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0311f5ea9382388d6124f.md @@ -198,9 +198,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -228,9 +228,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -252,9 +252,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f033fdb1fbcc254999fcc3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f033fdb1fbcc254999fcc3.md index 45960a5c100..4966b5001ef 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f033fdb1fbcc254999fcc3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f033fdb1fbcc254999fcc3.md @@ -207,9 +207,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -237,9 +237,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -261,9 +261,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03446c2ed3e264be6c7fc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03446c2ed3e264be6c7fc.md index b722d9266cb..01342688fa9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03446c2ed3e264be6c7fc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03446c2ed3e264be6c7fc.md @@ -201,9 +201,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -231,9 +231,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -255,9 +255,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0348a54a177272071a595.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0348a54a177272071a595.md index a138e683421..9dc29aef003 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0348a54a177272071a595.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0348a54a177272071a595.md @@ -213,9 +213,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -243,9 +243,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -267,9 +267,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f034d012f74627ce538d3a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f034d012f74627ce538d3a.md index b64d6cf4641..be379907633 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f034d012f74627ce538d3a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f034d012f74627ce538d3a.md @@ -221,9 +221,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -251,9 +251,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -275,9 +275,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03686c5ea863533ec71f4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03686c5ea863533ec71f4.md index ce0dd3a8980..f1bd4db6b6d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03686c5ea863533ec71f4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03686c5ea863533ec71f4.md @@ -203,9 +203,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -233,9 +233,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -257,9 +257,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f036ec91fdf238c90665f5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f036ec91fdf238c90665f5.md index 85163103f3d..d64bd092ccc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f036ec91fdf238c90665f5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f036ec91fdf238c90665f5.md @@ -201,9 +201,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -231,9 +231,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -255,9 +255,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0370b340915399d31e5eb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0370b340915399d31e5eb.md index ee8434c017a..3482b685a6c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0370b340915399d31e5eb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0370b340915399d31e5eb.md @@ -215,9 +215,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -245,9 +245,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -269,9 +269,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0374d5351223a747c301d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0374d5351223a747c301d.md index 246ea3f83f6..b46d11cdf9b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0374d5351223a747c301d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0374d5351223a747c301d.md @@ -241,9 +241,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -271,9 +271,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -295,9 +295,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0378e173e3c3b7638b528.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0378e173e3c3b7638b528.md index be4351e4d48..d5653eb9f77 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0378e173e3c3b7638b528.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f0378e173e3c3b7638b528.md @@ -197,9 +197,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -227,9 +227,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -251,9 +251,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038a0ae041d3c5b0cdf23.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038a0ae041d3c5b0cdf23.md index f8cd179a770..484efcedb8a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038a0ae041d3c5b0cdf23.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038a0ae041d3c5b0cdf23.md @@ -195,9 +195,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -225,9 +225,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -249,9 +249,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038e671d3f73d5a041973.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038e671d3f73d5a041973.md index 489e46fb79b..77f2478cf5e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038e671d3f73d5a041973.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f038e671d3f73d5a041973.md @@ -211,9 +211,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -241,9 +241,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -265,9 +265,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f039dbcef7673e4e758fa3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f039dbcef7673e4e758fa3.md index 4add3f815ba..fd5dba18c68 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f039dbcef7673e4e758fa3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f039dbcef7673e4e758fa3.md @@ -216,9 +216,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -246,9 +246,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -270,9 +270,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03a7143a6ef3f7f3344f0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03a7143a6ef3f7f3344f0.md index fdd479cae1c..54086d531ef 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03a7143a6ef3f7f3344f0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03a7143a6ef3f7f3344f0.md @@ -209,9 +209,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -239,9 +239,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -263,9 +263,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03ac2b428b2404a5a7518.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03ac2b428b2404a5a7518.md index 4aafff80ed9..9fba9eada3c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03ac2b428b2404a5a7518.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03ac2b428b2404a5a7518.md @@ -195,9 +195,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -225,9 +225,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -249,9 +249,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03af535682e4138fdb915.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03af535682e4138fdb915.md index 5d597cb5048..1846d38901d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03af535682e4138fdb915.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03af535682e4138fdb915.md @@ -221,9 +221,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -251,9 +251,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -275,9 +275,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03b1ed5ab15420c057463.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03b1ed5ab15420c057463.md index 37da7105588..d5b6b15d765 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03b1ed5ab15420c057463.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f03b1ed5ab15420c057463.md @@ -213,9 +213,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -243,9 +243,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -267,9 +267,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, @@ -567,9 +567,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -597,9 +597,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -621,9 +621,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f6721d5110af243ef8f3d9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f6721d5110af243ef8f3d9.md index a67cfcdb9d1..ac5a63dd016 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f6721d5110af243ef8f3d9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-oop-by-building-a-shopping-cart/63f6721d5110af243ef8f3d9.md @@ -196,9 +196,9 @@ const products = [ }, { id: 2, - name: "French Macaroon", + name: "French Macaron", price: 3.99, - category: "Macaroon", + category: "Macaron", }, { id: 3, @@ -226,9 +226,9 @@ const products = [ }, { id: 7, - name: "Chocolate Macaroons (4 Pack)", + name: "Chocolate Macarons (4 Pack)", price: 9.99, - category: "Macaroon", + category: "Macaron", }, { id: 8, @@ -250,9 +250,9 @@ const products = [ }, { id: 11, - name: "Vanilla Macaroons (5 Pack)", + name: "Vanilla Macarons (5 Pack)", price: 11.99, - category: "Macaroon", + category: "Macaron", }, { id: 12, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652f948489abbb81e6bf5a01.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652f948489abbb81e6bf5a01.md index 7427f8c2516..b9f93b81cd3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652f948489abbb81e6bf5a01.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652f948489abbb81e6bf5a01.md @@ -16,16 +16,28 @@ Start by accessing the `#playlist-songs`, `#play`, and `#pause` elements with th # --hints-- +You should have a variable called `playlistSongs`. + +```js +assert.isDefined(playlistSongs); +``` + You should use `document.getElementById()` to get the `#playlist-songs` element. ```js assert.match(code, /document\.getElementById\(\s*('|"|`)playlist\-songs\1\s*\)/); ``` -You should assign the `#playlist-songs` element to the variable `playlistSongs`. Don't forget to use `const` to declare the variable. +You should assign the `#playlist-songs` element to the variable `playlistSongs`. ```js -assert.match(code, /const\s+playlistSongs\s*\=\s*document\.getElementById\(\s*('|"|`)playlist\-songs\1\s*\)/); +assert.equal(playlistSongs, document.getElementById('playlist-songs')); +``` + +You should have a variable called `playButton`. + +```js +assert.isDefined(playButton); ``` You should use `document.getElementById()` to get the `#play` element. @@ -34,10 +46,16 @@ You should use `document.getElementById()` to get the `#play` element. assert.match(code, /document\.getElementById\(\s*('|"|`)play\1\s*\)/); ``` -You should assign the `#play` element to the variable `playButton`. Don't forget to use `const` to declare the variable. +You should assign the `#play` element to the variable `playButton`. ```js -assert.match(code, /const\s+playButton\s*\=\s*document\.getElementById\(\s*('|"|`)play\1\s*\)/); +assert.equal(playButton, document.getElementById('play')); +``` + +You should have a variable called `pauseButton`. + +```js +assert.isDefined(pauseButton); ``` You should use `document.getElementById()` to get the `#pause` element. @@ -46,10 +64,10 @@ You should use `document.getElementById()` to get the `#pause` element. assert.match(code, /document\.getElementById\(\s*('|"|`)pause\1\s*\)/); ``` -You should assign the `#pause` element to the variable `pauseButton`. Don't forget to use `const` to declare the variable. +You should assign the `#pause` element to the variable `pauseButton`. ```js -assert.match(code, /const\s+pauseButton\s*\=\s*document\.getElementById\(\s*('|"|`)pause\1\s*\)/); +assert.equal(pauseButton, document.getElementById('pause')); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa2aee6374ad29b5d49b4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa2aee6374ad29b5d49b4.md index b9a1f287e74..6c4fb56603b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa2aee6374ad29b5d49b4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa2aee6374ad29b5d49b4.md @@ -13,16 +13,28 @@ Assign them to variables named `nextButton`, `previousButton`, and `shuffleButto # --hints-- +You should have a variable called `nextButton`. + +```js +assert.isDefined(nextButton); +``` + You should use `document.getElementById()` to get the `#next` element. ```js assert.match(code, /document\.getElementById\(\s*('|"|`)next\1\s*\)/); ``` -You should assign the `#next` element to the variable `nextButton`. Don't forget to use `const` to declare the variable. +You should assign the `#next` element to the variable `nextButton`. ```js -assert.match(code, /const\s+nextButton\s*\=\s*document\.getElementById\(\s*('|"|`)next\1\s*\)/); +assert.equal(nextButton, document.getElementById('next')); +``` + +You should have a variable called `previousButton`. + +```js +assert.isDefined(previousButton); ``` You should use `document.getElementById()` to get the `#previous` element. @@ -31,10 +43,16 @@ You should use `document.getElementById()` to get the `#previous` element. assert.match(code, /document\.getElementById\(\s*('|"|`)previous\1\s*\)/); ``` -You should assign the `#previous` element to the variable `previousButton`. Don't forget to use `const` to declare the variable. +You should assign the `#previous` element to the variable `previousButton`. ```js -assert.match(code, /const\s+previousButton\s*\=\s*document\.getElementById\(\s*('|"|`)previous\1\s*\)/); +assert.equal(previousButton, document.getElementById('previous')); +``` + +You should have a variable called `shuffleButton`. + +```js +assert.isDefined(shuffleButton); ``` You should use `document.getElementById()` to get the `#shuffle` element. @@ -43,10 +61,10 @@ You should use `document.getElementById()` to get the `#shuffle` element. assert.match(code, /document\.getElementById\(\s*('|"|`)shuffle\1\s*\)/); ``` -You should assign the `#shuffle` element to the variable `shuffleButton`. Don't forget to use `const` to declare the variable. +You should assign the `#shuffle` element to the variable `shuffleButton`. ```js -assert.match(code, /const\s+shuffleButton\s*\=\s*document\.getElementById\(\s*('|"|`)shuffle\1\s*\)/); +assert.equal(shuffleButton, document.getElementById('shuffle')); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa3c4968fa9d6f8f6d873.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa3c4968fa9d6f8f6d873.md index 83e9065b478..5a67e58ff9b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa3c4968fa9d6f8f6d873.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/652fa3c4968fa9d6f8f6d873.md @@ -13,10 +13,22 @@ Create an empty `allSongs` array. # --hints-- -You should use `const` to create an empty `allSongs` array. +You should have a variable called `allSongs`. ```js -assert.match(code, /const\s+allSongs\s*=\s*\[\s*\]/) +assert.isDefined(allSongs) +``` + +You should assign an array to your `allSongs` variable. + +```js +assert.isArray(allSongs) +``` + +Your array should be empty. + +```js +assert.isEmpty(allSongs) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65327e9c7ea42e125256b29a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65327e9c7ea42e125256b29a.md index be9d659e3a5..7b25035b163 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65327e9c7ea42e125256b29a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65327e9c7ea42e125256b29a.md @@ -18,13 +18,13 @@ Use `const` to create a variable named `audio` and set it equal to `new Audio()` You should use the `new` keyword to create an instance of the `Audio` object. ```js -assert.match(code, /new\s+Audio\(\s*\);?/) +assert.match(code, /new\s+Audio\(\s*\)\s*;?/) ``` You should assign the `Audio` object to a constant named `audio`. ```js -assert.match(code, /const\s+audio\s*=\s*new\s+Audio\(\s*\);?/) +assert.match(code, /const\s+audio\s*=\s*new\s+Audio\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653281af14be5f2055310f8e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653281af14be5f2055310f8e.md index adc3d75cb76..0a167a41edc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653281af14be5f2055310f8e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653281af14be5f2055310f8e.md @@ -13,12 +13,6 @@ Start by using the `let` keyword to declare a new variable called `userData` and # --hints-- -You should have a variable called `userData`. - -```js -assert.isDefined(userData); -``` - You should use the `let` keyword to create the `userData` variable. ```js diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653283d07b8f9d294aafa83b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653283d07b8f9d294aafa83b.md index dc74cc2d2b2..45d736989ca 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653283d07b8f9d294aafa83b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653283d07b8f9d294aafa83b.md @@ -1,8 +1,8 @@ --- id: 653283d07b8f9d294aafa83b -title: الخطوة 26 +title: Step 29 challengeType: 0 -dashedName: step-26 +dashedName: step-29 --- # --description-- @@ -40,7 +40,7 @@ assert.match(code, /const\s+playSong\s*=\s*\(?\s*id/) Your `playSong` function should be empty. ```js -assert.match(code, /const\s+playSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+playSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -656,18 +656,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65362bfd67d61d517deef191.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65362bfd67d61d517deef191.md index cb947876895..12ffe59a586 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65362bfd67d61d517deef191.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65362bfd67d61d517deef191.md @@ -1,8 +1,8 @@ --- id: 65362bfd67d61d517deef191 -title: الخطوة 27 +title: Step 30 challengeType: 0 -dashedName: step-27 +dashedName: step-30 --- # --description-- @@ -40,13 +40,13 @@ assert.match(code, /userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)/) Your `find` method should use strict equality to check if `song.id` is equal to `id`. ```js -assert.match(code, /userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\);?/) +assert.match(code, /userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\)\s*;?/) ``` Your `find` method should be assigned to a `song` constant. ```js -assert.match(code, /const\s+song\s*=\s*userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\);?/) +assert.match(code, /const\s+song\s*=\s*userData\?\.songs\.find\(\s*(\(\s*song\s*\)|song)\s*=>\s*(song\.id\s*===\s*id|id\s*===\s*song\.id)\s*\)\s*;?/) ``` # --seed-- @@ -664,18 +664,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653635c731206b718659d3d5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653635c731206b718659d3d5.md index 80bb7a1823a..ec22802986d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653635c731206b718659d3d5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653635c731206b718659d3d5.md @@ -1,8 +1,8 @@ --- id: 653635c731206b718659d3d5 -title: الخطوة 28 +title: Step 31 challengeType: 0 -dashedName: step-28 +dashedName: step-31 --- # --description-- @@ -16,19 +16,19 @@ Also, set the `audio.title` property equal to `song.title`. This tells the audio You should not modify the existing `playSong` function and its content. ```js -assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*===\s*id\s*\);?/) +assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*===\s*id\s*\)\s*;?/) ``` You should set `audio.src` to `song.src`. ```js -assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s*===\s*id\s*\);?\s*audio\.src\s*=\s*song\.src;?/) +assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s*===\s*id\s*\)\s*;?\s*audio\.src\s*=\s*song\.src\s*;?/) ``` You should set `audio.title` to `song.title`. ```js -assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s===\s*id\s*\);?\s*audio\.src\s*=\s*song\.src;?\s*audio\.title\s*=\s*song\.title;?\s*\};?/) +assert.match(code, /const\s+playSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.songs\.find\(\s*\(\s*song\s*\)\s=>\s*song\.id\s===\s*id\s*\)\s*;?\s*audio\.src\s*=\s*song\.src\s*;?\s*audio\.title\s*=\s*song\.title\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -647,18 +647,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653639d63a45a077333312c8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653639d63a45a077333312c8.md index 9fbec0fdd13..b315eeb7f3a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653639d63a45a077333312c8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653639d63a45a077333312c8.md @@ -1,8 +1,8 @@ --- id: 653639d63a45a077333312c8 -title: الخطوة 29 +title: Step 32 challengeType: 0 -dashedName: step-29 +dashedName: step-32 --- # --description-- @@ -23,7 +23,7 @@ assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*user You should set `audio.currentTime` to `0` inside your `if` block. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0;?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}/) ``` # --seed-- @@ -645,18 +645,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653641509b6e7681a9333245.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653641509b6e7681a9333245.md index 93fd224a523..4049bd430b1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653641509b6e7681a9333245.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653641509b6e7681a9333245.md @@ -1,8 +1,8 @@ --- id: 653641509b6e7681a9333245 -title: الخطوة 31 +title: Step 34 challengeType: 0 -dashedName: step-31 +dashedName: step-34 --- # --description-- @@ -18,7 +18,7 @@ Start by accessing the `userData` object and its `currentSong` property. Set its You should assign `song` to `userData.currentSong`. ```js -assert.match(code, /userData\.currentSong\s*=\s*song;?/) +assert.match(code, /userData\.currentSong\s*=\s*song\s*;?/) ``` # --seed-- @@ -645,18 +645,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65364566e84e378837fbaf2a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65364566e84e378837fbaf2a.md index 53ae86d8c39..e4398d0e54b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65364566e84e378837fbaf2a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65364566e84e378837fbaf2a.md @@ -1,15 +1,15 @@ --- id: 65364566e84e378837fbaf2a -title: الخطوة 33 +title: Step 36 challengeType: 0 -dashedName: step-33 +dashedName: step-36 --- # --description-- In previous steps you built out the functionality for playing a song. Now you need to add the functionality to the play button so that it will play the current song when it is clicked on. -Use the `addEventListener()` method and pass in a `click` event for the first argument and an empty callback function with arrow syntax for the second argument, e.g., `() => {}`. +Use the `addEventListener()` method and pass in a `"click"` event for the first argument and an empty callback function with arrow syntax for the second argument, e.g., `() => {}`. # --hints-- @@ -19,7 +19,7 @@ You should call the `addEventListener()` method on your `playButton` variable. assert.match(code, /playButton\.addEventListener\(/) ``` -Your event listener should listen for a `click` event. +Your event listener should listen for a `"click"` event. ```js assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1/) @@ -28,7 +28,7 @@ assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1/) You should use arrow syntax to pass in an empty callback into your event listener. Don't forget you also need an empty pair of curly braces. ```js -assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /playButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- @@ -660,18 +660,22 @@ const renderSongs = (array) => { --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653fb19b515fde28243f727a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653fb19b515fde28243f727a.md index 69d6efb2f2c..590355b67e1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653fb19b515fde28243f727a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/653fb19b515fde28243f727a.md @@ -7,29 +7,22 @@ dashedName: step-11 # --description-- -Now you need a way to display the songs in the UI. To do this, you'll create a `renderSongs` function using the arrow function syntax. +Now you need a way to display the songs in the UI (User Interface). To do this, you'll create a `renderSongs` function using the arrow function syntax. -An arrow function is a shorter and more concise way to write functions in JavaScript. It's a function expression, which is a function that's assigned to a variable. To write an arrow function, you can use the following syntax: +An arrow function is a shorter and more concise way to write functions in JavaScript. It's a function expression, which is a function that's assigned to a variable. + +Here is an example of an arrow function with a single parameter and a single expression in the function body: ```js -// Traditional function -function add(a, b) { - return a + b; -} -console.log(add(3, 5)); // Output: 8 - -// Arrow function -const addArrow = (a, b) => { - return a + b; +const exampleArrowFunction = (param) => { + return param }; -console.log(addArrow(3, 5)); // Output: 8 ``` -If the function body consists of a single expression, you don't need the curly braces and the `return` keyword. This is called an `implicit return`: +If the function body consists of a single expression, you can omit the curly braces and the `return` keyword. This is called an `implicit return`: ```js -const addArrow = (a, b) => a + b; -console.log(addArrow(3, 5)); // Output: 8 +const exampleArrowFunction = (param) => param; ``` Use the arrow function syntax to create a `renderSongs` function that takes in `array` as its parameter. @@ -51,7 +44,7 @@ assert.isFunction(renderSongs) Your `renderSongs` function should use the arrow function syntax. ```js -assert.match(code, /const\s+renderSongs\s*=\s*\(?.*\)?\s*=>\s*/) +assert.match(code, /const\s+renderSongs\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*/) ``` Your `renderSongs` function should take `array` as a parameter. @@ -63,7 +56,7 @@ assert.match(code, /const\s+renderSongs\s*=\s*\(?\s*array/) Your `renderSongs` function should be empty. ```js -assert.match(code, /const\s+renderSongs\s*=\s*\(?\s*array\s*\)?\s*=>\s*\{\s*\};?/) +assert.match(code, /const\s+renderSongs\s*=\s*(\(\s*array\s*\)|array)\s*=>\s*\{\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65420dcfc60580678dad7a92.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65420dcfc60580678dad7a92.md index 4de1d89afa6..6ab05d2e984 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65420dcfc60580678dad7a92.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65420dcfc60580678dad7a92.md @@ -28,13 +28,13 @@ assert.match(code, /return\s*`\s*]*\sid\s*=\s*('|")song-\$\{song\.id\}\1[^>]*>\s*<\/li>\s*`;?/) +assert.match(code, /return\s*`\s*]*\sid\s*=\s*('|")song-\$\{song\.id\}\1[^>]*>\s*<\/li>\s*`\s*;?/) ``` Your opening `li` tag should have a `class` attribute set to `playlist-song`. ```js -assert.match(code, /return\s*`\s*]*\sclass\s*=\s*('|")playlist-song\1[^>]*>\s*<\/li>\s*`;?/) +assert.match(code, /return\s*`\s*]*\sclass\s*=\s*('|")playlist-song\1[^>]*>\s*<\/li>\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md index 3adcfac7f2d..58b05b01443 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/654215fe7b4a899ddceb3b60.md @@ -13,7 +13,7 @@ The `join()` method is used to concatenate all the elements of an array into a s ```js const exampleArr = ["This", "is", "a", "sentence"]; -const sentence = exampleArray.join(" "); // Separator takes a space character +const sentence = exampleArr.join(" "); // Separator takes a space character console.log(sentence); // Output: "This is a sentence" ``` @@ -30,7 +30,7 @@ array.map().join(); You should add `join("")` to the existing code. ```js -assert.match(code, /\s*\s*\s*\s*<\/svg>\s*<\/button>\s*<\/li>\s*`;?\s*\}\s*\)\s*\.join\(\s*('|")\3\s*\);?/) +assert.match(code, /\s*\s*\s*\s*<\/svg>\s*<\/button>\s*<\/li>\s*`\s*;?\s*\}\s*\)\s*\.join\(\s*('|")\3\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65422ba173a18b1bedef1bb6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65422ba173a18b1bedef1bb6.md index 2aa27493512..d365016689f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65422ba173a18b1bedef1bb6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65422ba173a18b1bedef1bb6.md @@ -1,28 +1,28 @@ --- id: 65422ba173a18b1bedef1bb6 -title: الخطوة 34 +title: Step 37 challengeType: 0 -dashedName: step-34 +dashedName: step-37 --- # --description-- -Within the arrow function of the event listener, add an `if` to check if `userData?.currentSong` is `null`. +Within the arrow function of the event listener, add an `if` to check if `userData?.currentSong` is `falsey`. Inside the `if` block, call the `playSong()` function with the `id` of the first song in the `userData?.songs` array. This will ensure the first song in the playlist is played first. # --hints-- -You should create an `if` statement with the condition `userData?.currentSong === null`. +You should create an `if` statement with the condition `!userData?.currentSong`. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{/) +assert.match(code, /if\s*\((\s*\!userData\?\.currentSong\s*|\s*userData\?\.currentSong\s*===\s*null\s*|\s*userData\?\.currentSong\s*===\s*undefined\s*)\)\s*\{/) ``` You should call the `playSong` function with `userData?.songs[0].id` inside your `if` block. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/) +assert.match(code, /if\s*\((\s*\!userData\?\.currentSong\s*|\s*userData\?\.currentSong\s*===\s*null\s*|\s*userData\?\.currentSong\s*===\s*undefined\s*)\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/) ``` # --seed-- @@ -656,17 +656,21 @@ playButton.addEventListener("click", () => { --fcc-editable-region-- }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); + + return userData?.songs; +}; renderSongs(userData?.songs); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552127b2576c2fbc5ecc2ea.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552127b2576c2fbc5ecc2ea.md index d33162a405a..3c0bb600bf2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552127b2576c2fbc5ecc2ea.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552127b2576c2fbc5ecc2ea.md @@ -1,8 +1,8 @@ --- id: 6552127b2576c2fbc5ecc2ea -title: الخطوة 35 +title: Step 38 challengeType: 0 -dashedName: step-35 +dashedName: step-38 --- # --description-- @@ -16,20 +16,20 @@ This ensures that the currently playing song will continue to play when the play You should not modify the existing `if` statement and its content. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/) ``` You should add an `else` block to your `if` statement. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `playSong` function with `userData?.currentSong.id` in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*playSong\(\s*userData\?\.currentSong\.id\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*playSong\(\s*userData\?\.currentSong\.id\s*\)\s*;?\s*\}/) ``` # --seed-- @@ -666,17 +666,21 @@ playButton.addEventListener("click", () => { --fcc-editable-region-- }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); + + return userData?.songs; +}; renderSongs(userData?.songs); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521badc7b7470edf952372.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521badc7b7470edf952372.md index bf543568793..3cafebc0bf0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521badc7b7470edf952372.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521badc7b7470edf952372.md @@ -1,8 +1,8 @@ --- id: 65521badc7b7470edf952372 -title: الخطوة 37 +title: Step 40 challengeType: 0 -dashedName: step-37 +dashedName: step-40 --- # --description-- @@ -34,7 +34,7 @@ assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*/) Your `pauseSong` function should be empty. ```js -assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -674,18 +674,22 @@ playButton.addEventListener("click", () => { } }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521ec3bb117c195c4f6cb5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521ec3bb117c195c4f6cb5.md index eba902dc470..fc2e975c0e1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521ec3bb117c195c4f6cb5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65521ec3bb117c195c4f6cb5.md @@ -1,8 +1,8 @@ --- id: 65521ec3bb117c195c4f6cb5 -title: الخطوة 38 +title: Step 41 challengeType: 0 -dashedName: step-38 +dashedName: step-41 --- # --description-- @@ -16,13 +16,13 @@ To store the current time of the song when it is paused, set the `songCurrentTim You should not modify the existing `pauseSong` function and its content. ```js -assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\};?/) +assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*;?/) ``` You should assign `audio.currentTime` to `userData.songCurrentTime`. ```js -assert.match(code, /userData\.songCurrentTime\s*=\s*audio\.currentTime;?/) +assert.match(code, /userData\.songCurrentTime\s*=\s*audio\.currentTime\s*;?/) ``` # --seed-- @@ -664,18 +664,22 @@ playButton.addEventListener("click", () => { } }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655220a3fa5c3c200bc8e938.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655220a3fa5c3c200bc8e938.md index 6665bb41d46..b5155829381 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655220a3fa5c3c200bc8e938.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655220a3fa5c3c200bc8e938.md @@ -1,8 +1,8 @@ --- id: 655220a3fa5c3c200bc8e938 -title: الخطوة 39 +title: Step 42 challengeType: 0 -dashedName: step-39 +dashedName: step-42 --- # --description-- @@ -16,13 +16,13 @@ To finally pause the song, use the `pause()` method on the `audio` variable. `pa You should not modify the existing `pauseSong` function and its content. ```js -assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\.songCurrentTime\s*=\s*audio\.currentTime;?\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+pauseSong\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\.songCurrentTime\s*=\s*audio\.currentTime\s*;?\s*.*\s*.*\s*\}\s*;?/) ``` -You should use the `classList` property and the `remove()` method to remove the class `playing` from the `playButton`. +You should use the `classList` property and the `remove()` method to remove the class `"playing"` from the `playButton`. ```js -assert.match(code, /playButton\.classList\.remove\(\s*('|")playing\1\s*\);?/) +assert.match(code, /playButton\.classList\.remove\(\s*('|")playing\1\s*\)\s*;?/) ``` You should use the `pause()` method on your `audio` variable. @@ -671,18 +671,22 @@ playButton.addEventListener("click", () => { } }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552303a9a78704f8ff072e9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552303a9a78704f8ff072e9.md index 2a3d064079e..799de68e9db 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552303a9a78704f8ff072e9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552303a9a78704f8ff072e9.md @@ -1,15 +1,15 @@ --- id: 6552303a9a78704f8ff072e9 -title: الخطوة 40 +title: Step 43 challengeType: 0 -dashedName: step-40 +dashedName: step-43 --- # --description-- Now it is time to test out the pause button. -Add a `click` event listener to the `pauseButton` element, then pass in `pauseSong` as the second argument of the event listener. This is the function the event listener will run. +Add a `"click"` event listener to the `pauseButton` element, then pass in `pauseSong` as the second argument of the event listener. This is the function the event listener will run. Test out your app by first clicking on the play button followed by the pause button. You should see that everything is working as expected. @@ -21,7 +21,7 @@ You should call the `addEventListener()` method on your `pauseButton` variable. assert.match(code, /pauseButton\.addEventListener\(/) ``` -Your event listener should listen for a `click` event. +Your event listener should listen for a `"click"` event. ```js assert.match(code, /pauseButton\.addEventListener\(\s*('|"|`)click\1/) @@ -677,17 +677,21 @@ playButton.addEventListener("click", () => { --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655235c2e607297f00316650.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655235c2e607297f00316650.md index ec7d994bf62..a75078887be 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655235c2e607297f00316650.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655235c2e607297f00316650.md @@ -1,28 +1,28 @@ --- id: 655235c2e607297f00316650 -title: الخطوة 32 +title: Step 35 challengeType: 0 -dashedName: step-32 +dashedName: step-35 --- # --description-- -Next, use the `classList` property and the `add()` method to add the `playing` class to the `playButton` element. This will look for the class `playing` in the CSS file and add it to the `playButton` element. +Next, use the `classList` property and the `add()` method to add the `"playing"` class to the `playButton` element. This will look for the class `"playing"` in the CSS file and add it to the `playButton` element. To finally play the song, use the `play()` method on the `audio` variable. `play()` is a method from the web audio API for playing an mp3 file. # --hints-- -You should use the `classList` property and the `add` method to add the class `playing` to `playButton`. +You should use the `classList` property and the `add` method to add the class `"playing"` to `playButton`. ```js -assert.match(code, /playButton\.classList\.add\(\s*("|')playing\1\s*\);?/) +assert.match(code, /playButton\.classList\.add\(\s*("|')playing\1\s*\)\s*;?/) ``` You should use the `play()` method on the `audio` variable. ```js -assert.match(code, /audio\.play\(\s*\);?/) +assert.match(code, /audio\.play\(\s*\)\s*;?/) ``` # --seed-- @@ -651,18 +651,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552385244ccf89b77d6b332.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552385244ccf89b77d6b332.md index ced6464aca0..6119f932a6f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552385244ccf89b77d6b332.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6552385244ccf89b77d6b332.md @@ -1,8 +1,8 @@ --- id: 6552385244ccf89b77d6b332 -title: الخطوة 43 +title: Step 46 challengeType: 0 -dashedName: step-43 +dashedName: step-46 --- # --description-- @@ -34,7 +34,7 @@ assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*/) Your `playNextSong` function should be empty. ```js -assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -685,17 +685,21 @@ playButton.addEventListener("click", () => { pauseButton.addEventListener("click", pauseSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655243068222c2c1166b90b0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655243068222c2c1166b90b0.md index 8079fdf35d7..4b26299f894 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655243068222c2c1166b90b0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655243068222c2c1166b90b0.md @@ -1,8 +1,8 @@ --- id: 655243068222c2c1166b90b0 -title: الخطوة 44 +title: Step 47 challengeType: 0 -dashedName: step-44 +dashedName: step-47 --- # --description-- @@ -16,7 +16,7 @@ If the condition is true, call the `playSong` function with the `id` of the firs You should not modify the existing `playNextSong` function and its content. ```js -assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+playNextSong\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*.*\s*\}\s*;?/) ``` You should create an `if` statement with the condition `userData?.currentSong === null`. @@ -32,7 +32,7 @@ You should call the `playSong` function with `userData?.songs[0].id` inside the ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/) ``` # --seed-- @@ -685,17 +685,21 @@ playButton.addEventListener("click", () => { pauseButton.addEventListener("click", pauseSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655476e1ff522252fdcce5e4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655476e1ff522252fdcce5e4.md index e27eb12d0ab..046e2ce86da 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655476e1ff522252fdcce5e4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655476e1ff522252fdcce5e4.md @@ -1,8 +1,8 @@ --- id: 655476e1ff522252fdcce5e4 -title: الخطوة 45 +title: Step 48 challengeType: 0 -dashedName: step-45 +dashedName: step-48 --- # --description-- @@ -16,7 +16,7 @@ You should not modify the existing `if` statement. ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}/) ``` You should add an `else` to the existing `if` statement. @@ -24,7 +24,7 @@ You should add an `else` to the existing `if` statement. ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` You should set the `currentSongIndex` constant to `getCurrentSongIndex()` inside the `else` block. @@ -32,7 +32,7 @@ You should set the `currentSongIndex` constant to `getCurrentSongIndex()` inside ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*\}/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*\}/) ``` @@ -690,17 +690,21 @@ playButton.addEventListener("click", () => { pauseButton.addEventListener("click", pauseSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655479aa3e1e0360ae38b7a6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655479aa3e1e0360ae38b7a6.md index 113aca26638..27f5f0656a9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655479aa3e1e0360ae38b7a6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655479aa3e1e0360ae38b7a6.md @@ -1,8 +1,8 @@ --- id: 655479aa3e1e0360ae38b7a6 -title: الخطوة 46 +title: Step 49 challengeType: 0 -dashedName: step-46 +dashedName: step-49 --- # --description-- @@ -20,7 +20,7 @@ You should not modify the existing `if` statement, its `else` block, and content ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*/) ``` You should assign `userData?.songs[currentSongIndex + 1]` to a `nextSong` constant. @@ -28,7 +28,7 @@ You should assign `userData?.songs[currentSongIndex + 1]` to a `nextSong` consta ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*/) ``` You should call the `playSong` function with `nextSong.id`. @@ -36,7 +36,7 @@ You should call the `playSong` function with `nextSong.id`. ```js const splitter = code.split('const getCurrentSongIndex = () => userData?.songs.indexOf(userData?.currentSong);') -assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\);?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*playSong\(\s*nextSong\.id\s*\);?\s*\}/) +assert.match(splitter[0], /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{\s*playSong\(\s*userData\?\.songs\s*\[\s*0\s*\]\s*\.id\s*\)\s*;?\s*\}\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+nextSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*\+\s*1\s*\]\s*;?\s*playSong\(\s*nextSong\.id\s*\)\s*;?\s*\}/) ``` @@ -695,17 +695,21 @@ playButton.addEventListener("click", () => { pauseButton.addEventListener("click", pauseSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65547ee197840478a1b95f4b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65547ee197840478a1b95f4b.md index 203d9800b1a..9250088eb41 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65547ee197840478a1b95f4b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65547ee197840478a1b95f4b.md @@ -1,15 +1,15 @@ --- id: 65547ee197840478a1b95f4b -title: الخطوة 47 +title: Step 50 challengeType: 0 -dashedName: step-47 +dashedName: step-50 --- # --description-- Now it is time to test out the `playNextSong` function. -Add a `click` event listener to the `nextButton` element, then pass in `playNextSong` as the second argument of your event listener. This is the function the event listener will run. +Add a `"click"` event listener to the `nextButton` element, then pass in `playNextSong` as the second argument of your event listener. This is the function the event listener will run. Test out your app by first clicking on the play button followed by the next button. You should see that everything is working as expected. @@ -21,7 +21,7 @@ You should call the `addEventListener()` method on your `nextButton` variable. assert.match(code, /nextButton\.addEventListener\(/) ``` -Your event listener should listen for a `click` event. +Your event listener should listen for a `"click"` event. ```js assert.match(code, /nextButton\.addEventListener\(\s*('|"|`)click\1/) @@ -693,17 +693,21 @@ pauseButton.addEventListener("click", pauseSong); --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554815fe2472f8bfdab7642.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554815fe2472f8bfdab7642.md index 759c9516b8f..b4f30684980 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554815fe2472f8bfdab7642.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554815fe2472f8bfdab7642.md @@ -1,8 +1,8 @@ --- id: 6554815fe2472f8bfdab7642 -title: الخطوة 48 +title: Step 51 challengeType: 0 -dashedName: step-48 +dashedName: step-51 --- # --description-- @@ -32,7 +32,7 @@ assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*/) Your `playPreviousSong` function should be empty. ```js -assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -697,17 +697,21 @@ pauseButton.addEventListener("click", pauseSong); nextButton.addEventListener("click", playNextSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655482742cc5499726e3f347.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655482742cc5499726e3f347.md index daf1f48e786..d6b8dd086e8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655482742cc5499726e3f347.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655482742cc5499726e3f347.md @@ -1,8 +1,8 @@ --- id: 655482742cc5499726e3f347 -title: الخطوة 49 +title: Step 52 challengeType: 0 -dashedName: step-49 +dashedName: step-52 --- # --description-- @@ -28,19 +28,19 @@ assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s You should have `return` inside the block of your `if` statement. ```js -assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?/) +assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*/) +assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*/) ``` You should call `getCurrentSongIndex` and assign it to `currentSongIndex` inside the `else` block of your `if` statement. ```js -assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*/) +assert.match(code, /const\s+playPreviousSong\s*=\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*/) ``` @@ -709,17 +709,21 @@ pauseButton.addEventListener("click", pauseSong); nextButton.addEventListener("click", playNextSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655483ebf0096ba02b2c3d4c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655483ebf0096ba02b2c3d4c.md index 734c4f3c077..fa177fb8190 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655483ebf0096ba02b2c3d4c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655483ebf0096ba02b2c3d4c.md @@ -1,8 +1,8 @@ --- id: 655483ebf0096ba02b2c3d4c -title: الخطوة 50 +title: Step 53 challengeType: 0 -dashedName: step-50 +dashedName: step-53 --- # --description-- @@ -14,19 +14,19 @@ To get the previous song, subtract `1` from the `currentSongIndex` of `userData? You should not modify the existing `if` statement and its content. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*/) ``` You should assign `userData?.songs[currentSongIndex - 1]` to a `previousSong` constant. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*/) ``` You should call the `playSong` function with `previousSong.id`. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*playSong\(\s*previousSong\.id\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\)\s*\{?\s*return\s*;?\s*\}?\s*else\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*const\s+previousSong\s*=\s*userData\?\.songs\s*\[\s*currentSongIndex\s*-\s*1\s*\]\s*;?\s*playSong\(\s*previousSong\.id\s*\)\s*;?\s*\}/) ``` # --seed-- @@ -697,17 +697,21 @@ pauseButton.addEventListener("click", pauseSong); nextButton.addEventListener("click", playNextSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655485321913feabbc5f00f8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655485321913feabbc5f00f8.md index 3843502696f..9e41708ae46 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655485321913feabbc5f00f8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655485321913feabbc5f00f8.md @@ -1,13 +1,13 @@ --- id: 655485321913feabbc5f00f8 -title: الخطوة 51 +title: Step 54 challengeType: 0 -dashedName: step-51 +dashedName: step-54 --- # --description-- -Add a `click` event listener to the `previousButton` element, then pass in `playPreviousSong` as the second argument. +Add a `"click"` event listener to the `previousButton` element, then pass in `playPreviousSong` as the second argument. # --hints-- @@ -17,7 +17,7 @@ You should call the `addEventListener()` method on your `previousButton` variabl assert.match(code, /previousButton\.addEventListener\(/) ``` -Your event listener should listen for a `click` event. +Your event listener should listen for a `"click"` event. ```js assert.match(code, /previousButton\.addEventListener\(\s*('|"|`)click\1/) @@ -701,17 +701,21 @@ nextButton.addEventListener("click", playNextSong); --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554860ea4dfbab2f4786fc8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554860ea4dfbab2f4786fc8.md index e14a0b04358..1b818159026 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554860ea4dfbab2f4786fc8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6554860ea4dfbab2f4786fc8.md @@ -1,8 +1,8 @@ --- id: 6554860ea4dfbab2f4786fc8 -title: الخطوة 52 +title: Step 55 challengeType: 0 -dashedName: step-52 +dashedName: step-55 --- # --description-- @@ -40,7 +40,7 @@ assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*{\s*const\ You should use the `querySelectorAll()` method to select the `.playlist-song` element and assign it to the `playlistSongElements` constant. ```js -assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\);?\s*\};?/) +assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -716,17 +716,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655487f686aabfc2a10ba887.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655487f686aabfc2a10ba887.md index dda67f7dad7..08e083ee670 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655487f686aabfc2a10ba887.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655487f686aabfc2a10ba887.md @@ -1,8 +1,8 @@ --- id: 655487f686aabfc2a10ba887 -title: الخطوة 41 +title: Step 44 challengeType: 0 -dashedName: step-41 +dashedName: step-44 --- # --description-- @@ -671,17 +671,21 @@ playButton.addEventListener("click", () => { pauseButton.addEventListener("click", pauseSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65548f747a4cdafd186948d1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65548f747a4cdafd186948d1.md index 4a48bfe9d26..53f0d25a1fc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65548f747a4cdafd186948d1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65548f747a4cdafd186948d1.md @@ -1,8 +1,8 @@ --- id: 65548f747a4cdafd186948d1 -title: الخطوة 53 +title: Step 56 challengeType: 0 -dashedName: step-53 +dashedName: step-56 --- # --description-- @@ -16,19 +16,19 @@ Use `getElementById()` to get the `id` of the currently playing song, then use t You should not modify the existing `highlightCurrentSong` function and its content. ```js -assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*\s{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\);?\s*/) +assert.match(code, /const\s+highlightCurrentSong\s*=\s*\(\s*\)\s*=>\s*\s{\s*const\s+playlistSongElements\s*=\s*document\.querySelectorAll\(\s*('|")\.playlist-song\1\s*\)\s*;?\s*/) ``` You should use `document.getElementById()` and pass in `` `song-${userData?.currentSong?.id}` ``. ```js -assert.match(code, /document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\);?\s*\};?/) +assert.match(code, /document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\)\s*;?\s*\}\s*;?/) ``` You should assign your `getElementById()` to a `songToHighlight` constant. ```js -assert.match(code, /const\s+songToHighlight\s*=\s*document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\);?\s*\};?/) +assert.match(code, /const\s+songToHighlight\s*=\s*document\.getElementById\(\s*`song-\$\{userData\?\.currentSong\?\.id\}`\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -708,17 +708,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655490f55c36900779336988.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655490f55c36900779336988.md index e76438d14dd..73bf31846e5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655490f55c36900779336988.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655490f55c36900779336988.md @@ -1,8 +1,8 @@ --- id: 655490f55c36900779336988 -title: الخطوة 54 +title: Step 57 challengeType: 0 -dashedName: step-54 +dashedName: step-57 --- # --description-- @@ -33,13 +33,13 @@ assert.match(code, /playlistSongElements\.forEach\(/) Your `forEach()` method should have a `songEl` parameter and use arrow syntax. ```js -assert.match(code, /playlistSongElements\.forEach\(\s*(\(songEl\s*\)|songEl)\s*=>\s*/) +assert.match(code, /playlistSongElements\.forEach\(\s*(\(\s*songEl\s*\)|songEl)\s*=>\s*/) ``` Your `forEach` should have an empty pair of curly braces. ```js -assert.match(code, /playlistSongElements\.forEach\(\s*(\(songEl\s*\)|songEl)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /playlistSongElements\.forEach\(\s*(\(\s*songEl\s*\)|songEl)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- @@ -722,17 +722,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655492e6b90c7a198c587943.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655492e6b90c7a198c587943.md index e394ae062e5..5163904d19e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655492e6b90c7a198c587943.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655492e6b90c7a198c587943.md @@ -1,8 +1,8 @@ --- id: 655492e6b90c7a198c587943 -title: الخطوة 56 +title: Step 59 challengeType: 0 -dashedName: step-56 +dashedName: step-59 --- # --description-- @@ -715,17 +715,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655494d5a15d6a2567e1ea60.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655494d5a15d6a2567e1ea60.md index 651fffd5af4..d7b8a2a2ed8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655494d5a15d6a2567e1ea60.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655494d5a15d6a2567e1ea60.md @@ -1,8 +1,8 @@ --- id: 655494d5a15d6a2567e1ea60 -title: الخطوة 57 +title: Step 60 challengeType: 0 -dashedName: step-57 +dashedName: step-60 --- # --description-- @@ -704,17 +704,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655495a6bd96e42bc3baa795.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655495a6bd96e42bc3baa795.md index 618920dc7b6..de9645055bd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655495a6bd96e42bc3baa795.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655495a6bd96e42bc3baa795.md @@ -1,8 +1,8 @@ --- id: 655495a6bd96e42bc3baa795 -title: الخطوة 58 +title: Step 61 challengeType: 0 -dashedName: step-58 +dashedName: step-61 --- # --description-- @@ -32,7 +32,7 @@ assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*/) Your `setPlayerDisplay` function should be empty. ```js -assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -722,17 +722,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d17af9ff06a14d399f6d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d17af9ff06a14d399f6d.md index 95ea0cc54a3..0441b4dc541 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d17af9ff06a14d399f6d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d17af9ff06a14d399f6d.md @@ -1,8 +1,8 @@ --- id: 6555d17af9ff06a14d399f6d -title: الخطوة 59 +title: Step 62 challengeType: 0 -dashedName: step-59 +dashedName: step-62 --- # --description-- @@ -16,31 +16,31 @@ Access the `#player-song-title` and `#player-song-artist` elements with the `get You should not modify the existing `setPlayerDisplay` function and its content. ```js -assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+setPlayerDisplay\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*\}\s*;?/) ``` You should use `document.getElementById()` to get the `#player-song-title` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\);?/); +assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\)\s*;?/); ``` You should assign the `#player-song-title` element to the variable `playingSong`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+playingSong\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\);?/); +assert.match(code, /const\s+playingSong\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-title\1\s*\)\s*;?/); ``` You should use `document.getElementById()` to get the `#player-song-artist` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\);?/); +assert.match(code, /document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\)\s*;?/); ``` You should assign the `#player-song-artist` element to the variable `songArtist`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+songArtist\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\);?/); +assert.match(code, /const\s+songArtist\s*\=\s*document\.getElementById\(\s*('|"|`)player\-song\-artist\1\s*\)\s*;?/); ``` # --seed-- @@ -732,17 +732,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d458687cb3b357834df9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d458687cb3b357834df9.md index 6905e1c51ab..444a71c4c54 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d458687cb3b357834df9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d458687cb3b357834df9.md @@ -1,8 +1,8 @@ --- id: 6555d458687cb3b357834df9 -title: الخطوة 60 +title: Step 63 challengeType: 0 -dashedName: step-60 +dashedName: step-63 --- # --description-- @@ -14,25 +14,25 @@ Access the `userData?.currentSong?.title` and `userData?.currentSong?.artist` pr You should access the `title` of `currentSong` from the `userData` object. Don't forget to use optional chaining. ```js -assert.match(code, /userData\?\.currentSong\?\.title;?/) +assert.match(code, /userData\?\.currentSong\?\.title\s*;?/) ``` You should assign the `title` of the `currentSong` to a `currentTitle` constant. ```js -assert.match(code, /const\s+currentTitle\s*=\s*userData\?\.currentSong\?\.title;?/) +assert.match(code, /const\s+currentTitle\s*=\s*userData\?\.currentSong\?\.title\s*;?/) ``` You should access the `artist` of `currentSong` from the `userData` object. Don't forget to use optional chaining. ```js -assert.match(code, /userData\?\.currentSong\?\.artist;?/) +assert.match(code, /userData\?\.currentSong\?\.artist\s*;?/) ``` You should assign the `artist` of the `currentSong` to a `currentArtist` constant. ```js -assert.match(code, /const\s+currentArtist\s*=\s*userData\?\.currentSong\?\.artist;?/) +assert.match(code, /const\s+currentArtist\s*=\s*userData\?\.currentSong\?\.artist\s*;?/) ``` # --seed-- @@ -726,17 +726,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d729c9bfd7c3195f1948.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d729c9bfd7c3195f1948.md index 0803e7974b5..a092ed520f1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d729c9bfd7c3195f1948.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d729c9bfd7c3195f1948.md @@ -1,8 +1,8 @@ --- id: 6555d729c9bfd7c3195f1948 -title: الخطوة 61 +title: Step 64 challengeType: 0 -dashedName: step-61 +dashedName: step-64 --- # --description-- @@ -18,9 +18,9 @@ const element = document.getElementById('example'); console.log(element.textContent); // Output: This is some text content ``` -Use a `ternary` operator to check if `currentTitle` is truthy. If so, implicitly return `currentTitle` otherwise implicitly return an empty string. Assign this result to `playingSong.textContent`. +Use a ternary operator to check if `currentTitle` evaluates to a truthy value. If it does, set `playingSong.textContent` to `currentTitle`. Otherwise, set it to an empty string. -Then, use a `ternary` operator to check if `currentArtist` is truthy. If so, implicitly return `currentArtist` otherwise implicitly return an empty string. Assign this result to `songArtist.textContent`. +Then below that, use a `ternary` operator to check if `currentArtist` is truthy. If so, set `songArtist.textContent` to `currentArtist`. Otherwise, set it to empty string. # --hints-- @@ -33,7 +33,7 @@ assert.match(code, /playingSong\.textContent\s*/) You should use the `ternary` operator to set the `textContent` property of `playingSong` to `currentTitle` or `""`. ```js -assert.match(code, /playingSong\.textContent\s*=\s*currentTitle\s*\?\s*currentTitle\s*:\s*('|")\1;?/) +assert.match(code, /playingSong\.textContent\s*=\s*currentTitle\s*\?\s*currentTitle\s*:\s*('|")\1\s*;?/) ``` You should chain the `textContent` property to `songArtist`. @@ -45,7 +45,7 @@ assert.match(code, /songArtist\.textContent\s*/) You should use the `ternary` operator to set the `textContent` property of `songArtist` to `currentArtist` or `""`. ```js -assert.match(code, /songArtist\.textContent\s*=\s*currentArtist\s*\?\s*currentArtist\s*:\s*('|")\1;?/) +assert.match(code, /songArtist\.textContent\s*=\s*currentArtist\s*\?\s*currentArtist\s*:\s*('|")\1\s*;?/) ``` # --seed-- @@ -741,17 +741,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d7e384056dc9c581fadf.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d7e384056dc9c581fadf.md index b848dd1af49..77c3d760040 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d7e384056dc9c581fadf.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d7e384056dc9c581fadf.md @@ -1,8 +1,8 @@ --- id: 6555d7e384056dc9c581fadf -title: الخطوة 62 +title: Step 65 challengeType: 0 -dashedName: step-62 +dashedName: step-65 --- # --description-- @@ -16,7 +16,7 @@ Now you should see the song title and the artist show up in the display. You should call the `setPlayerDisplay` function inside your `playSong` function. ```js -assert.match(code, /setPlayerDisplay\(\s*\);?/) +assert.match(code, /setPlayerDisplay\(\s*\)\s*;?/) ``` # --seed-- @@ -715,17 +715,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d8faed60b9d3e4a6cefb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d8faed60b9d3e4a6cefb.md index 8c1698bd9b4..44a3c16f0eb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d8faed60b9d3e4a6cefb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555d8faed60b9d3e4a6cefb.md @@ -1,8 +1,8 @@ --- id: 6555d8faed60b9d3e4a6cefb -title: الخطوة 63 +title: Step 66 challengeType: 0 -dashedName: step-63 +dashedName: step-66 --- # --description-- @@ -34,7 +34,7 @@ assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*/) Your `setPlayButtonAccessibleText` function should be empty. ```js -assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -735,17 +735,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555dd138e70cae6b546966d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555dd138e70cae6b546966d.md index e4762acc334..9bf6b675847 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555dd138e70cae6b546966d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555dd138e70cae6b546966d.md @@ -1,8 +1,8 @@ --- id: 6555dd138e70cae6b546966d -title: الخطوة 64 +title: Step 67 challengeType: 0 -dashedName: step-64 +dashedName: step-67 --- # --description-- @@ -16,7 +16,7 @@ Don't forget to use optional chaining. You should not modify the existing `setPlayButtonAccessibleText` and its content. ```js -assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\};?/) +assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*;?/) ``` You should access `userData?.currentSong` or `userData?.songs[0]`. @@ -731,17 +731,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555de565387a2efe90a6ccc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555de565387a2efe90a6ccc.md index 54d312ec5b9..4dd34d2c6c3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555de565387a2efe90a6ccc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555de565387a2efe90a6ccc.md @@ -1,13 +1,13 @@ --- id: 6555de565387a2efe90a6ccc -title: الخطوة 65 +title: Step 68 challengeType: 0 -dashedName: step-65 +dashedName: step-68 --- # --description-- -Use the `setAttribute` method on the `playButton` element to set an attribute named `aria-label`. For the value, use a `ternary` to set `song?.title` to `Play ${song.title}` or `"Play"` if there's no `song.title` available. +Use the `setAttribute` method on the `playButton` element to set an attribute named `"aria-label"`. For the value, use a `ternary` to set `song?.title` to `Play ${song.title}` or `"Play"` if there's no `song.title` available. Don't forget you need template interpolation here, so you need to use backticks. @@ -16,7 +16,7 @@ Don't forget you need template interpolation here, so you need to use backticks. You should not modify the existing `setPlayButtonAccessibleText` function and its content. ```js -assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.currentSong\s*\|\|\s*userData\?\.songs\s*\[\s*0\s*\]\s*;?\s*.*\s*.*\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+setPlayButtonAccessibleText\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+song\s*=\s*userData\?\.currentSong\s*\|\|\s*userData\?\.songs\s*\[\s*0\s*\]\s*;?\s*.*\s*.*\s*.*\s*.*\s*\}\s*;?/) ``` You should use the `setAttribute()` method on `playButton`. @@ -34,7 +34,7 @@ assert.match(code, /playButton\.setAttribute\(\s*('|")aria-label\1/) Your `setAttribute` method should have ``song?.title ? `Play ${song.title}` : "Play"`` as the second argument. ```js -assert.match(code, /playButton\.setAttribute\(\s*('|")aria-label\1\s*,\s*song\?\.title\s*\?\s*`Play\s*\$\{song\.title\}`\s*:\s*('|")Play\2\s*\);?\s*/) +assert.match(code, /playButton\.setAttribute\(\s*('|")aria-label\1\s*,\s*song\?\.title\s*\?\s*`Play\s*\$\{song\.title\}`\s*:\s*('|")Play\2\s*\)\s*;?\s*/) ``` # --seed-- @@ -738,17 +738,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e04aeb225bfbae237344.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e04aeb225bfbae237344.md index 97bbe40f014..78be8af4587 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e04aeb225bfbae237344.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e04aeb225bfbae237344.md @@ -1,8 +1,8 @@ --- id: 6555e04aeb225bfbae237344 -title: الخطوة 66 +title: Step 69 challengeType: 0 -dashedName: step-66 +dashedName: step-69 --- # --description-- @@ -14,7 +14,7 @@ Now, call the `setPlayButtonAccessibleText` function inside the `playSong` funct You should call the `setPlayButtonAccessibleText` inside your `playSong` function. ```js -assert.match(code, /setPlayButtonAccessibleText\(\s*\);?/) +assert.match(code, /setPlayButtonAccessibleText\(\s*\)\s*;?/) ``` # --seed-- @@ -723,17 +723,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e0bfe4d69904410f7cd3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e0bfe4d69904410f7cd3.md index 911f4ff74b8..41b8acf3378 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e0bfe4d69904410f7cd3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e0bfe4d69904410f7cd3.md @@ -1,8 +1,8 @@ --- id: 6555e0bfe4d69904410f7cd3 -title: الخطوة 67 +title: Step 70 challengeType: 0 -dashedName: step-67 +dashedName: step-70 --- # --description-- @@ -34,7 +34,7 @@ assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*/) Your `shuffle` function should be empty. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -745,17 +745,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e39a5f4c6f138c7d9405.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e39a5f4c6f138c7d9405.md index dbae70d71f5..82d3db56485 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e39a5f4c6f138c7d9405.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e39a5f4c6f138c7d9405.md @@ -1,8 +1,8 @@ --- id: 6555e39a5f4c6f138c7d9405 -title: الخطوة 68 +title: Step 71 challengeType: 0 -dashedName: step-68 +dashedName: step-71 --- # --description-- @@ -24,7 +24,7 @@ Use the `sort()` method on the `userData?.songs` array. Pass a callback to the m You should not modify the existing `shuffle` function. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*[\s\S]*?\};?/); +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*{\s*[\s\S]*?\}\s*;?/); ``` You should use the `sort()` method on `userData?.songs`. @@ -42,7 +42,7 @@ assert.match(code, /userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*/) The callback of your `sort()` method should return `Math.random() - 0.5`. ```js -assert.match(code, /userData\?.songs\.sort\s*\(\s*\(\s*\)\s*=>(\s*{\s*return\s+Math\.random\(\s*\)\s*-\s*0\.5\s*;?\s*}\s*)|(\s*Math\.random\(\s*\)\s*-\s*0\.5\s*)\s*\);?/); +assert.match(code, /userData\?\.songs\.sort\s*\(\s*\(\s*\)\s*=>(\s*{\s*return\s+Math\.random\(\s*\)\s*-\s*0\.5\s*;?\s*}\s*)|(\s*Math\.random\(\s*\)\s*-\s*0\.5\s*)\s*\)\s*;?/); ``` # --seed-- @@ -755,17 +755,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e57d3e6d9d221c4735be.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e57d3e6d9d221c4735be.md index 1f2ffefc8c0..947b939102b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e57d3e6d9d221c4735be.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e57d3e6d9d221c4735be.md @@ -1,8 +1,8 @@ --- id: 6555e57d3e6d9d221c4735be -title: الخطوة 69 +title: Step 72 challengeType: 0 -dashedName: step-69 +dashedName: step-72 --- # --description-- @@ -18,13 +18,13 @@ Set `userData.currentSong` to `null` and `userData.songCurrentTime` to `0`. You should set `userData.currentSong` to `null`. ```js -assert.match(code, /userData\.currentSong\s*=\s*null;?/) +assert.match(code, /userData\.currentSong\s*=\s*null\s*;?/) ``` You should set `userData.songCurrentTime` to `0`. ```js -assert.match(code, /userData\.songCurrentTime\s*=\s*0;?/) +assert.match(code, /userData\.songCurrentTime\s*=\s*0\s*;?/) ``` # --seed-- @@ -738,17 +738,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e6cec786da2aadc11ea0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e6cec786da2aadc11ea0.md index c8eb8a8c7e1..08806539762 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e6cec786da2aadc11ea0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e6cec786da2aadc11ea0.md @@ -1,8 +1,8 @@ --- id: 6555e6cec786da2aadc11ea0 -title: الخطوة 70 +title: Step 73 challengeType: 0 -dashedName: step-70 +dashedName: step-73 --- # --description-- @@ -16,31 +16,31 @@ Call the `renderSongs` function and pass in `userData?.songs` as an argument. Al You should not modify the existing `shuffle` function and its content. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*.*\s*.*\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*.*\s*.*\s*.*\s*.*\s*\}\s*;?/) ``` You should call the `renderSongs` function with `userData?.songs`. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*.*\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}\s*;?/) ``` You should call the `pauseSong` function. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*pauseSong\(\s*\);?\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*pauseSong\(\s*\)\s*;?\s*.*\s*.*\s*\}\s*;?/) ``` You should call the `setPlayerDisplay` function. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*pauseSong\(\s*\);?\s*setPlayerDisplay\(\s*\);?\s*.*\s*\};?/) +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*pauseSong\(\s*\)\s*;?\s*setPlayerDisplay\(\s*\)\s*;?\s*.*\s*\}\s*;?/) ``` You should call the `setPlayButtonAccessibleText` function. ```js -assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\);?\s*userData\.currentSong\s*=\s*null;\s*userData\.songCurrentTime\s*=\s*0;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*pauseSong\(\s*\);?\s*setPlayerDisplay\(\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*\};?/) +assert.match(code, /const\s+shuffle\s*=\s*\(\s*\)\s*=>\s*\{\s*userData\?\.songs\.sort\(\s*\(\s*\)\s*=>\s*Math\.random\(\s*\)\s*-\s*0\.5\s*\)\s*;?\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*pauseSong\(\s*\)\s*;?\s*setPlayerDisplay\(\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -757,17 +757,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e7acdbae972d3e8e0f5b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e7acdbae972d3e8e0f5b.md index becebdae3d6..cb1d88ed201 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e7acdbae972d3e8e0f5b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e7acdbae972d3e8e0f5b.md @@ -1,13 +1,13 @@ --- id: 6555e7acdbae972d3e8e0f5b -title: الخطوة 71 +title: Step 74 challengeType: 0 -dashedName: step-71 +dashedName: step-74 --- # --description-- -Add a `click` event listener to the `shuffleButton` element. For the function to run, pass in the `shuffle` function. +Add a `"click"` event listener to the `shuffleButton` element. For the function to run, pass in the `shuffle` function. **Note**: You don't need a callback inside this particular event listener. You also don't need to call the `shuffle` function, just pass in its identifier. @@ -19,16 +19,16 @@ You should chain the `addEventListener()` method to `shuffleButton`. assert.match(code, /shuffleButton\.addEventListener\(/) ``` -Your event listener should listen for a `click` event. +Your event listener should listen for a `"click"` event. ```js assert.match(code, /shuffleButton\.addEventListener\(\s*('|")click\1/) ``` -You should pass in `shuffle` as the second value of your `click` event listener. +You should pass in `shuffle` as the second value of your `"click"` event listener. ```js -assert.match(code, /shuffleButton\.addEventListener\(\s*('|")click\1\s*,\s*shuffle\s*\);?/) +assert.match(code, /shuffleButton\.addEventListener\(\s*('|")click\1\s*,\s*shuffle\s*\)\s*;?/) ``` # --seed-- @@ -750,17 +750,21 @@ previousButton.addEventListener("click", playPreviousSong); --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e9197bf1d7416bdd76e0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e9197bf1d7416bdd76e0.md index 5ab90ce02a4..b2863ba2e7c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e9197bf1d7416bdd76e0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555e9197bf1d7416bdd76e0.md @@ -1,8 +1,8 @@ --- id: 6555e9197bf1d7416bdd76e0 -title: الخطوة 72 +title: Step 75 challengeType: 0 -dashedName: step-72 +dashedName: step-75 --- # --description-- @@ -40,7 +40,7 @@ assert.match(code, /const\s+deleteSong\s*=\s*\(?\s*id/) Your `deleteSong` function should be empty. ```js -assert.match(code, /const\s+deleteSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+deleteSong\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- @@ -764,17 +764,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555ebf07ec610585a626f72.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555ebf07ec610585a626f72.md index 2c6779735a9..17cc28826ab 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555ebf07ec610585a626f72.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6555ebf07ec610585a626f72.md @@ -1,8 +1,8 @@ --- id: 6555ebf07ec610585a626f72 -title: الخطوة 73 +title: Step 76 challengeType: 0 -dashedName: step-73 +dashedName: step-76 --- # --description-- @@ -27,7 +27,7 @@ Use the `filter()` method on `userData?.songs`. Pass in `song` as the parameter You should not modify the existing `deleteSong` function. ```js -assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*.*\s*\};?/) +assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*.*\s*\}\s*;?/) ``` You should use the `filter()` method on `userData?.songs`. @@ -777,17 +777,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65571e742fbf4532d8f98e90.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65571e742fbf4532d8f98e90.md index 719bdf58497..9b18eb34595 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65571e742fbf4532d8f98e90.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65571e742fbf4532d8f98e90.md @@ -1,8 +1,8 @@ --- id: 65571e742fbf4532d8f98e90 -title: الخطوة 74 +title: Step 77 challengeType: 0 -dashedName: step-74 +dashedName: step-77 --- # --description-- @@ -18,25 +18,25 @@ After that, call the `highlightCurrentSong` function to highlight the current so You should not modify the existing `deleteSong` function and its content. ```js -assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*.*\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}\s*;?/) ``` You should call the `renderSongs` function with `userData?.songs`. ```js -assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*.*\s*.*\s*\};?/) +assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*.*\s*.*\s*\}\s*;?/) ``` You should call the `highlightCurrentSong` function. ```js -assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*highlightCurrentSong\(\s*\);?\s*.*\s*\};?/) +assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*highlightCurrentSong\(\s*\)\s*;?\s*.*\s*\}\s*;?/) ``` You should call the `setPlayButtonAccessibleText` function. ```js -assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\);?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*highlightCurrentSong\(\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteSong\s*=\s*\(\s*id\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*userData\?\.songs\.filter\(\s*\(\s*song\s*\)\s*=>\s*song\.id\s*!==\s*id\s*\)\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\)\s*;?\s*highlightCurrentSong\(\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -763,17 +763,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655720534347cb3f31cdfb3d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655720534347cb3f31cdfb3d.md index 974b693f0e5..ec8f6e45ebf 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655720534347cb3f31cdfb3d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655720534347cb3f31cdfb3d.md @@ -1,8 +1,8 @@ --- id: 655720534347cb3f31cdfb3d -title: الخطوة 75 +title: Step 78 challengeType: 0 -dashedName: step-75 +dashedName: step-78 --- # --description-- @@ -748,17 +748,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572399a8e16d50bc2c1ff3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572399a8e16d50bc2c1ff3.md index b99fd08fe67..7d8e3d48a72 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572399a8e16d50bc2c1ff3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572399a8e16d50bc2c1ff3.md @@ -1,8 +1,8 @@ --- id: 65572399a8e16d50bc2c1ff3 -title: الخطوة 76 +title: Step 79 challengeType: 0 -dashedName: step-76 +dashedName: step-79 --- # --description-- @@ -22,25 +22,25 @@ assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{ You should set `userData.currentSong` to `null`. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*.*\s*.*\s*.*\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*.*\s*.*\s*.*\s*\}/) ``` You should set `userData.songCurrentTime` to `0`. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*.*\s*.*\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*.*\s*.*\s*\}/) ``` You should call the `pauseSong` function. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*pauseSong\(\s*\);?\s*.*\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*pauseSong\(\s*\)\s*;?\s*.*\s*\}/) ``` You should call the `setPlayerDisplay` function. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*pauseSong\(\s*\);?\s*setPlayerDisplay\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\?\.id\s*===\s*id\s*\)\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*pauseSong\(\s*\)\s*;?\s*setPlayerDisplay\(\s*\)\s*;?\s*\}/) ``` # --seed-- @@ -773,17 +773,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655724bac464795a0ad91082.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655724bac464795a0ad91082.md index b27131aaa23..7a3f79830b1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655724bac464795a0ad91082.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655724bac464795a0ad91082.md @@ -1,8 +1,8 @@ --- id: 655724bac464795a0ad91082 -title: الخطوة 78 +title: Step 81 challengeType: 0 -dashedName: step-78 +dashedName: step-81 --- # --description-- @@ -756,17 +756,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655727b2e1e49d6adf584442.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655727b2e1e49d6adf584442.md index e1f1afcd856..80774d8e867 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655727b2e1e49d6adf584442.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655727b2e1e49d6adf584442.md @@ -1,8 +1,8 @@ --- id: 655727b2e1e49d6adf584442 -title: الخطوة 79 +title: Step 82 challengeType: 0 -dashedName: step-79 +dashedName: step-82 --- # --description-- @@ -25,7 +25,7 @@ You can also assign it to a variable: const divElement = document.createElement('div') ``` -Inside your `if` statement, declare a `resetButton` constant, then use `createElement()` to create a `button`. +Inside your `if` statement, declare a `resetButton` constant, then use `createElement()` to create a `"button"`. # --hints-- @@ -36,16 +36,16 @@ You should not modify the existing `if` statement and its content. assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*.*\s*\}/) ``` -You should use the `createElement` method to create a `button`. +You should use the `createElement` method to create a `"button"`. ```js -assert.match(code, /document\.createElement\(\s*('|")button\1\s*\);?/) +assert.match(code, /document\.createElement\(\s*('|")button\1\s*\)\s*;?/) ``` You should assign your newly created `button` element to a `resetButton` constant. ```js -assert.match(code, /const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\);?/) +assert.match(code, /const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\)\s*;?/) ``` # --seed-- @@ -787,17 +787,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655729e68e49b277a6b448bd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655729e68e49b277a6b448bd.md index 8aa85dd2cdb..9b1147eafbd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655729e68e49b277a6b448bd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655729e68e49b277a6b448bd.md @@ -1,8 +1,8 @@ --- id: 655729e68e49b277a6b448bd -title: الخطوة 81 +title: Step 84 challengeType: 0 -dashedName: step-81 +dashedName: step-84 --- # --description-- @@ -11,26 +11,26 @@ Now that you've created the `resetButton`, you need to assign it an `id` and `ar For example, `element.id` would set an `id` attribute, and `element.ariaLabel` would set an `aria-label` attribute. Both of them accept their values as a string. -Set the `id` attribute of `resetButton` to `reset` and its `aria-label` attribute to `Reset playlist`. +Set the `id` attribute of `resetButton` to `"reset"` and its `"aria-label"` attribute to `"Reset playlist"`. # --hints-- You should not modify the existing `if` statement and its content. ```js -assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\);?\s*.*\s*.*\s*.*\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}/) ``` -You should use `resetButton.id` to create an `id` attribute named `reset` for the `resetButton`. +You should use `resetButton.id` to create an `id` attribute named `"reset"` for the `resetButton`. ```js assert.match(code, /resetButton\.id\s*=\s*('|")reset\1/) ``` -You should use `resetButton.ariaLabel` to create an `aria-label` attribute named `Reset playlist` for the `resetButton`. +You should use `resetButton.ariaLabel` to create an `"aria-label"` attribute named `"Reset playlist"` for the `resetButton`. ```js -assert.match(code, /resetButton\.ariaLabel\s*=\s*('|")Reset\s+playlist\1;?/) +assert.match(code, /resetButton\.ariaLabel\s*=\s*('|")Reset\s+playlist\1\s*;?/) ``` # --seed-- @@ -775,17 +775,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572bb34a7e488224b937fc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572bb34a7e488224b937fc.md index 3ea189e33f2..cedc2428796 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572bb34a7e488224b937fc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572bb34a7e488224b937fc.md @@ -1,8 +1,8 @@ --- id: 65572bb34a7e488224b937fc -title: الخطوة 82 +title: Step 85 challengeType: 0 -dashedName: step-82 +dashedName: step-85 --- # --description-- @@ -32,7 +32,7 @@ assert.match(code, /resetButton\.appendChild\(/) You should pass in `resetText` as the value of your first `appendChild()`. ```js -assert.match(code, /resetButton\.appendChild\(\s*resetText\s*\);?/) +assert.match(code, /resetButton\.appendChild\(\s*resetText\s*\)\s*;?/) ``` You should use the `appendChild()` method on `playlistSongs`. @@ -44,7 +44,7 @@ assert.match(code, /playlistSongs\.appendChild\(/) You should pass in `resetButton` as the value of your second `appendChild()`. ```js -assert.match(code, /playlistSongs\.appendChild\(\s*resetButton\s*\);?/) +assert.match(code, /playlistSongs\.appendChild\(\s*resetButton\s*\)\s*;?/) ``` # --seed-- @@ -791,17 +791,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572e5aaf022790fb4a81b1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572e5aaf022790fb4a81b1.md index 2ddd29bd769..681d6779329 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572e5aaf022790fb4a81b1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65572e5aaf022790fb4a81b1.md @@ -1,8 +1,8 @@ --- id: 65572e5aaf022790fb4a81b1 -title: الخطوة 83 +title: Step 86 challengeType: 0 -dashedName: step-83 +dashedName: step-86 --- # --description-- @@ -19,7 +19,7 @@ You should use the `addEventListener()` method on `resetButton`. assert.match(code, /resetButton\.addEventListener\(/) ``` -Your `resetButton` event listener should listen for a `click` event. +Your `resetButton` event listener should listen for a `"click"` event. ```js assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1/) @@ -28,7 +28,7 @@ assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1/) The callback function of your event listener should use arrow syntax and have an empty pair of curly braces. ```js -assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- @@ -778,17 +778,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655737cd004591b0271d6826.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655737cd004591b0271d6826.md index 11e41995afc..fd102396e71 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655737cd004591b0271d6826.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655737cd004591b0271d6826.md @@ -1,8 +1,8 @@ --- id: 655737cd004591b0271d6826 -title: الخطوة 84 +title: Step 87 challengeType: 0 -dashedName: step-84 +dashedName: step-87 --- # --description-- @@ -16,7 +16,7 @@ To reset the playlist to its original state, spread `allSongs` into an array and You should not modify the existing event listener and its content. ```js -assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*\);?/) +assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*.*\s*\}\s*\)\s*;?/) ``` You should assign `[...allSongs]` to `userData.songs`. @@ -775,17 +775,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573a97c59ddbbf028ca95e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573a97c59ddbbf028ca95e.md index 47afa9c2eea..730c6499c13 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573a97c59ddbbf028ca95e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573a97c59ddbbf028ca95e.md @@ -1,15 +1,15 @@ --- id: 65573a97c59ddbbf028ca95e -title: الخطوة 85 +title: Step 88 challengeType: 0 -dashedName: step-85 +dashedName: step-88 --- # --description-- Finally, you should render the songs again, update the play button's accessible text, and remove the reset button from the playlist. You also need to remove the `resetButton` from the DOM. -Call the `renderSongs()` function with `userData?.songs` as an argument to render the songs again. +Call the `renderSongs()` function with `sortSongs()` as an argument to render the songs again in alphabetical order. Call the `setPlayButtonAccessibleText()` function to update the play button's accessible text. @@ -22,25 +22,25 @@ Remove the reset button from the playlist by calling the `remove()` method on th You should not modify the existing event listener and its content. ```js -assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*.*\s*.*\s*.*\s*\}\s*\);?/) +assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*.*\s*.*\s*.*\s*\}\s*\)\s*;?/) ``` -You should call the `renderSongs` function with `userData?.songs`. +You should call the `renderSongs` function with `sortSongs()`. ```js -assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*.*\s*.*\s*\}\s*\);?/) +assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\s*\)\s*\)\s*;?\s*.*\s*.*\s*\}\s*\)\s*;?/) ``` You should call the `setPlayButtonAccessibleText` function. ```js -assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*.*\s*\}\s*\);?/) +assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\s*\)\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*.*\s*\}\s*\)\s*;?/) ``` You should use the `remove()` method to remove the `resetButton` from the DOM. ```js -assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*userData\?\.songs\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?\s*resetButton\.remove\(\s*\);?\s*\}\s*\);?/) +assert.match(code, /resetButton\.addEventListener\(\s*('|")click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*userData\.songs\s*=\s*\[\s*\.\.\.allSongs\s*\]\s*;?\s*renderSongs\(\s*sortSongs\(\s*\)\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?\s*resetButton\.remove\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- @@ -794,17 +794,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573d0abe4d38cd6fa13f44.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573d0abe4d38cd6fa13f44.md index b8f9ed7bd15..f01e94a7df1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573d0abe4d38cd6fa13f44.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65573d0abe4d38cd6fa13f44.md @@ -1,17 +1,17 @@ --- id: 65573d0abe4d38cd6fa13f44 -title: الخطوة 86 +title: Step 89 challengeType: 0 -dashedName: step-86 +dashedName: step-89 --- # --description-- All the core functionalities are now in place. The only issue now is that the next song does not automatically play when the currently playing song ends. -To fix that, you can set up an event listener which will detect when the currently playing song ends. The `ended` event listener is appropriate for this. It is fired when the playback of a media reaches the end. +To fix that, you can set up an event listener which will detect when the currently playing song ends. The `"ended"` event listener is appropriate for this. It is fired when the playback of a media reaches the end. -Add an event listener to the `audio` element which listens for the `ended` event. Pass in a callback using arrow syntax with empty curly braces. +Add an event listener to the `audio` element which listens for the `"ended"` event. Pass in a callback using arrow syntax with empty curly braces. # --hints-- @@ -21,16 +21,16 @@ You should chain the `addEventListener()` method to your `audio` variable. assert.match(code, /audio\.addEventListener\(/) ``` -The event listener you used on on your `audio` variable should listen for an `ended` event. +The event listener you used on on your `audio` variable should listen for an `"ended"` event. ```js assert.match(code, /audio\.addEventListener\(\s*('|")ended\1/) ``` -You should use arrow syntax to pass in an empty callback to your `ended` event listener. +You should use arrow syntax to pass in an empty callback to your `"ended"` event listener. ```js -assert.match(code, /audio\.addEventListener\(\s*('|")ended\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /audio\.addEventListener\(\s*('|")ended\1\s*,\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` @@ -705,7 +705,7 @@ const deleteSong = (id) => { resetButton.addEventListener("click", () => { userData.songs = [...allSongs]; - renderSongs(userData?.songs); + renderSongs(sortSongs()); setPlayButtonAccessibleText(); resetButton.remove(); }); @@ -790,18 +790,22 @@ shuffleButton.addEventListener("click", shuffle); --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); setPlayButtonAccessibleText(); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6557421eb6a7a0f0500e3106.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6557421eb6a7a0f0500e3106.md index 0ab2bbc31be..b409bf6dea7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6557421eb6a7a0f0500e3106.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6557421eb6a7a0f0500e3106.md @@ -1,8 +1,8 @@ --- id: 6557421eb6a7a0f0500e3106 -title: الخطوة 77 +title: Step 80 challengeType: 0 -dashedName: step-77 +dashedName: step-80 --- # --description-- @@ -11,7 +11,7 @@ Within the button element in the `renderSongs` function, add an `onclick` attrib # --hints-- -You should add an `onclick` attribute to the delete button and pass in `deleteSong(${song.id})`. +You should add an `onclick` attribute to the delete button and pass in `"deleteSong(${song.id})"`. ```js assert.match(code, //) @@ -752,17 +752,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b49333d9f265bc1512152.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b49333d9f265bc1512152.md index bea8f798fc2..721f5c2bb06 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b49333d9f265bc1512152.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b49333d9f265bc1512152.md @@ -1,8 +1,8 @@ --- id: 655b49333d9f265bc1512152 -title: الخطوة 87 +title: Step 90 challengeType: 0 -dashedName: step-87 +dashedName: step-90 --- # --description-- @@ -18,13 +18,13 @@ After that, create a `nextSongExists` constant that contains the boolean value ` You should not modify the existing `ended` event listener and its content. ```js -assert.match(code, /audio\.addEventListener\(\s*('|")ended\1\s*,\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*\}\s*\);?/) +assert.match(code, /audio\.addEventListener\(\s*('|")ended\1\s*,\s*\(\s*\)\s*=>\s*\{\s*.*\s*.*\s*\}\s*\)\s*;?/) ``` You should create a `currentSongIndex` constant and set it to the calling of the `getCurrentSongIndex` function. ```js -assert.match(code, /audio\.addEventListener\(\s*('|")ended\1\s*,\s*\(\s*\)\s*=>\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\);?\s*.*\s*\}\s*\);?/) +assert.match(code, /audio\.addEventListener\(\s*('|")ended\1\s*,\s*\(\s*\)\s*=>\s*\{\s*const\s+currentSongIndex\s*=\s*getCurrentSongIndex\(\s*\)\s*;?\s*.*\s*\}\s*\)\s*;?/) ``` You should check if a next song exists comparing `userData.songs.length` and `currentSongIndex` and set it to a `nextSongExists` constant. If the last index of the songs array (`userData.songs.length - 1`) is bigger than the currentSongIndex that means there is a next song. @@ -674,7 +674,7 @@ const deleteSong = (id) => { resetButton.addEventListener("click", () => { userData.songs = [...allSongs]; - renderSongs(userData?.songs); + renderSongs(sortSongs()); setPlayButtonAccessibleText(); resetButton.remove(); }); @@ -761,18 +761,22 @@ audio.addEventListener("ended", () => { }); --fcc-editable-region-- -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); setPlayButtonAccessibleText(); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4bbff1dbf66cb2ed4dac.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4bbff1dbf66cb2ed4dac.md index cedafb01fea..289a47c017d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4bbff1dbf66cb2ed4dac.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4bbff1dbf66cb2ed4dac.md @@ -1,8 +1,8 @@ --- id: 655b4bbff1dbf66cb2ed4dac -title: الخطوة 88 +title: Step 91 challengeType: 0 -dashedName: step-88 +dashedName: step-91 --- # --description-- @@ -20,7 +20,7 @@ assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*/) You should call the `playNextSong` function inside your `if` statement. ```js -assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\)\s*;?\s*\}/) ``` # --seed-- @@ -659,7 +659,7 @@ const deleteSong = (id) => { resetButton.addEventListener("click", () => { userData.songs = [...allSongs]; - renderSongs(userData?.songs); + renderSongs(sortSongs()); setPlayButtonAccessibleText(); resetButton.remove(); }); @@ -748,18 +748,22 @@ audio.addEventListener("ended", () => { --fcc-editable-region-- }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); setPlayButtonAccessibleText(); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4c8f636d9675953a0388.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4c8f636d9675953a0388.md index b83c088cd3f..a30f4fbf6b2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4c8f636d9675953a0388.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4c8f636d9675953a0388.md @@ -1,8 +1,8 @@ --- id: 655b4c8f636d9675953a0388 -title: الخطوة 89 +title: Step 92 challengeType: 0 -dashedName: step-89 +dashedName: step-92 --- # --description-- @@ -14,25 +14,25 @@ If there is no next song in the playlist, use the `else` block to reset the `cur You should not modify the existing `if` statement and its content. ```js -assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\);?\s*.*\s*.*\s*.*\s*\};?/) +assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\)\s*;?\s*.*\s*.*\s*.*\s*\}\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\);?\s*\}\s*else\s*\{\s*.*\s*.*\s*\};?/) +assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\)\s*;?\s*\}\s*else\s*\{\s*.*\s*.*\s*\}\s*;?/) ``` You should use dot notation to set the `currentSong` property of `userData` to `null` in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\);?\s*\}\s*else\s*\{\s*userData\.currentSong\s*=\s*null;?\s*.*\s*\};?/) +assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\)\s*;?\s*\}\s*else\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*.*\s*\}\s*;?/) ``` You should use dot notation to set the `songCurrentTime` property of `userData` to `0` in the `else` block of your `if`statement. ```js -assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\);?\s*\}\s*else\s*\{\s*userData\.currentSong\s*=\s*null;?\s*userData\.songCurrentTime\s*=\s*0;?\s*\};?/) +assert.match(code, /if\s*\(\s*nextSongExists\s*\)\s*\{\s*playNextSong\(\s*\)\s*;?\s*\}\s*else\s*\{\s*userData\.currentSong\s*=\s*null\s*;?\s*userData\.songCurrentTime\s*=\s*0\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -671,7 +671,7 @@ const deleteSong = (id) => { resetButton.addEventListener("click", () => { userData.songs = [...allSongs]; - renderSongs(userData?.songs); + renderSongs(sortSongs()); setPlayButtonAccessibleText(); resetButton.remove(); }); @@ -764,18 +764,22 @@ audio.addEventListener("ended", () => { --fcc-editable-region-- }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); setPlayButtonAccessibleText(); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4dad1d38ff7cdd65cbfe.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4dad1d38ff7cdd65cbfe.md index d018700ab70..c433170b239 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4dad1d38ff7cdd65cbfe.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655b4dad1d38ff7cdd65cbfe.md @@ -1,8 +1,8 @@ --- id: 655b4dad1d38ff7cdd65cbfe -title: الخطوة 90 +title: Step 93 challengeType: 0 -dashedName: step-90 +dashedName: step-93 --- # --description-- @@ -17,28 +17,28 @@ You should call the `pauseSong` function. ```js const splitter = code.split('audio.addEventListener("ended", () => {') -assert.match(splitter[1], /pauseSong\(\s*\);?/) +assert.match(splitter[1], /pauseSong\(\s*\)\s*;?/) ``` You should call the `setPlayerDisplay` function. ```js const splitter = code.split('audio.addEventListener("ended", () => {') -assert.match(splitter[1], /setPlayerDisplay\(\s*\);?/) +assert.match(splitter[1], /setPlayerDisplay\(\s*\)\s*;?/) ``` You should call the `highlightCurrentSong` function. ```js const splitter = code.split('audio.addEventListener("ended", () => {') -assert.match(splitter[1], /highlightCurrentSong\(\s*\);?/) +assert.match(splitter[1], /highlightCurrentSong\(\s*\)\s*;?/) ``` You should call the `setPlayButtonAccessibleText` function. ```js const splitter = code.split('audio.addEventListener("ended", () => {') -assert.match(splitter[1], /highlightCurrentSong\(\s*\);?\s*setPlayButtonAccessibleText\(\s*\);?/) +assert.match(splitter[1], /highlightCurrentSong\(\s*\)\s*;?\s*setPlayButtonAccessibleText\(\s*\)\s*;?/) ``` # --seed-- @@ -712,7 +712,7 @@ const deleteSong = (id) => { resetButton.addEventListener("click", () => { userData.songs = [...allSongs]; - renderSongs(userData?.songs); + renderSongs(sortSongs()); setPlayButtonAccessibleText(); resetButton.remove(); }); @@ -809,19 +809,23 @@ audio.addEventListener("ended", () => { } }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); setPlayButtonAccessibleText(); ``` @@ -1494,7 +1498,7 @@ const deleteSong = (id) => { resetButton.addEventListener("click", () => { userData.songs = [...allSongs]; - renderSongs(userData?.songs); + renderSongs(sortSongs()); setPlayButtonAccessibleText(); resetButton.remove(); }); @@ -1592,18 +1596,22 @@ audio.addEventListener("ended", () => { } }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); setPlayButtonAccessibleText(); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655dc43318591b975cdfe2d8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655dc43318591b975cdfe2d8.md index 2120459e238..5fd5b062a69 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655dc43318591b975cdfe2d8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/655dc43318591b975cdfe2d8.md @@ -37,25 +37,25 @@ Your `allSongs` array should have an object with an `id` property set to the num assert.equal(allSongs[0].id, 0); ``` -Your `allSongs` array should have an object with a `title` property set to the string `Scratching The Surface`. +Your `allSongs` array should have an object with a `title` property set to the string `"Scratching The Surface"`. ```js assert.equal(allSongs[0].title, "Scratching The Surface"); ``` -Your `allSongs` array should have an object with an `artist` property set to the string `Quincy Larson`. +Your `allSongs` array should have an object with an `artist` property set to the string `"Quincy Larson"`. ```js assert.equal(allSongs[0].artist, "Quincy Larson"); ``` -Your `allSongs` array should have an object with a `duration` property set to the string `4:25`. +Your `allSongs` array should have an object with a `duration` property set to the string `"4:25"`. ```js assert.equal(allSongs[0].duration, "4:25"); ``` -Your `allSongs` array should have an object with an `src` property set to the string `https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3`. +Your `allSongs` array should have an object with an `src` property set to the string `"https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3"`. ```js assert.equal(allSongs[0].src, "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3"); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606d06666e118ba86162be.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606d06666e118ba86162be.md index a995335896c..756bfdeaa5d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606d06666e118ba86162be.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606d06666e118ba86162be.md @@ -37,25 +37,25 @@ The second object in your `allSongs` array should have an `id` property set to t assert.equal(allSongs[1].id, 1); ``` -The second object in your `allSongs` array should have a `title` property set to the string `Can't Stay Down`. +The second object in your `allSongs` array should have a `title` property set to the string `"Can't Stay Down"`. ```js assert.equal(allSongs[1].title, "Can't Stay Down"); ``` -The second object in your `allSongs` array should have an `artist` property set to the string `Quincy Larson`. +The second object in your `allSongs` array should have an `artist` property set to the string `"Quincy Larson"`. ```js assert.equal(allSongs[1].artist, "Quincy Larson"); ``` -The second object in your `allSongs` array should have a `duration` property set to the string `4:15`. +The second object in your `allSongs` array should have a `duration` property set to the string `"4:15"`. ```js assert.equal(allSongs[1].duration, "4:15"); ``` -The second object in your `allSongs` array should have an `src` property set to the string `https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3`. +The second object in your `allSongs` array should have an `src` property set to the string `"https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3"`. ```js assert.equal(allSongs[1].src, "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3"); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606ed6ea2baca053327e9b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606ed6ea2baca053327e9b.md index f5f0af9bc7f..be4543e978f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606ed6ea2baca053327e9b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65606ed6ea2baca053327e9b.md @@ -31,25 +31,25 @@ The third object in your `allSongs` array should have an `id` property set to th assert.equal(allSongs[2].id, 2); ``` -The third object in your `allSongs` array should have a `title` property set to the string `Still Learning`. +The third object in your `allSongs` array should have a `title` property set to the string `"Still Learning"`. ```js assert.equal(allSongs[2].title, "Still Learning"); ``` -The third object in your `allSongs` array should have an `artist` property set to the string `Quincy Larson`. +The third object in your `allSongs` array should have an `artist` property set to the string `"Quincy Larson"`. ```js assert.equal(allSongs[2].artist, "Quincy Larson"); ``` -The third object in your `allSongs` array should have a `duration` property set to the string `3:51`. +The third object in your `allSongs` array should have a `duration` property set to the string `"3:51"`. ```js assert.equal(allSongs[2].duration, "3:51"); ``` -The third object in your `allSongs` array should have an `src` property set to the string `https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3`. +The third object in your `allSongs` array should have an `src` property set to the string `"https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3"`. ```js assert.equal(allSongs[2].src, "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3"); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656071d679089ebd9d5035a0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656071d679089ebd9d5035a0.md index 7e400a4ac5e..455bb402c31 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656071d679089ebd9d5035a0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656071d679089ebd9d5035a0.md @@ -23,10 +23,16 @@ Inside the `userData` object create a `songs` property. For the value, spread `a # --hints-- -Your `userData` object should have a `songs` key set to `[...allSongs]`. +Your `userData` object should have a key called `songs`. ```js -assert.match(code, /songs\s*:\s*\[\s*\.\.\.allSongs\s*\]\s*,?/); +assert.property(userData, "songs"); +``` + +Your `songs` property should have a value of `[...allSongs]`. + +```js +assert.deepPropertyVal(userData, "songs", [...allSongs]); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656472ed8f552d2f2b3f7883.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656472ed8f552d2f2b3f7883.md index 67c923e2b3a..93935fb487e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656472ed8f552d2f2b3f7883.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/656472ed8f552d2f2b3f7883.md @@ -1,8 +1,8 @@ --- id: 656472ed8f552d2f2b3f7883 -title: الخطوة 30 +title: Step 33 challengeType: 0 -dashedName: step-30 +dashedName: step-33 --- # --description-- @@ -16,19 +16,19 @@ Within the `else` block, set the `currentTime` property of the `audio` object to You should not modify the existing `if` statement and its content. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0;?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}/) ``` You should add an `else` block to the existing `if` block. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0;?\s*\}\s*else\s*{/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}\s*else\s*{/) ``` You should set `audio.currentTime` to `userData?.songCurrentTime` inside the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0;?\s*\}\s*else\s*{\s*audio\.currentTime\s*=\s*userData\?\.songCurrentTime;?\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.currentSong\s*===\s*null\s*\|\|\s*userData\?\.currentSong\.id\s*!==\s*song\.id\s*\)\s*\{\s*audio\.currentTime\s*=\s*0\s*;?\s*\}\s*else\s*{\s*audio\.currentTime\s*=\s*userData\?\.songCurrentTime\s*;?\s*\}/) ``` # --seed-- @@ -654,18 +654,22 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6567055f59d39f07d1c542dc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6567055f59d39f07d1c542dc.md index 6c91c5781fa..ac224341d5b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6567055f59d39f07d1c542dc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/6567055f59d39f07d1c542dc.md @@ -16,7 +16,7 @@ Assign `songsHTML` to the `innerHTML` property of the `playlistSongs` element. T You should use the `innerHTML` property to add `songsHTML` to `playlistSongs`. ```js -assert.match(code, /playlistSongs\.innerHTML\s*=\s*songsHTML;?/) +assert.match(code, /playlistSongs\.innerHTML\s*=\s*songsHTML\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65671421254eeb489875cdd8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65671421254eeb489875cdd8.md index 70a21266b3f..7cc17e8e650 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65671421254eeb489875cdd8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65671421254eeb489875cdd8.md @@ -1,8 +1,8 @@ --- id: 65671421254eeb489875cdd8 -title: الخطوة 55 +title: Step 58 challengeType: 0 -dashedName: step-55 +dashedName: step-58 --- # --description-- @@ -20,7 +20,7 @@ assert.match(code, /playlistSongElements\.forEach\(\s*(\(\s*songEl\s*\)|songEl)\ You should use the `removeAttribute()` method on `songEl` and pass in `"aria-current"`. ```js -assert.match(code, /playlistSongElements\.forEach\(\s*(?:\(\s*songEl\s*\)|songEl)\s*=>\s*\{\s*songEl\.removeAttribute\(\s*('|")aria-current\1\s*\);?\s*\}\s*\);?/) +assert.match(code, /playlistSongElements\.forEach\(\s*(?:\(\s*songEl\s*\)|songEl)\s*=>\s*\{\s*songEl\.removeAttribute\(\s*('|")aria-current\1\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` @@ -707,17 +707,21 @@ nextButton.addEventListener("click", playNextSong); previousButton.addEventListener("click", playPreviousSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672136535209761a5cf02b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672136535209761a5cf02b.md index 4a0c4cdd59c..8c397c35dbe 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672136535209761a5cf02b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672136535209761a5cf02b.md @@ -1,8 +1,8 @@ --- id: 65672136535209761a5cf02b -title: الخطوة 36 +title: Step 39 challengeType: 0 -dashedName: step-36 +dashedName: step-39 --- # --description-- @@ -654,17 +654,21 @@ playButton.addEventListener("click", () => { } }); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); + + return userData?.songs; +}; renderSongs(userData?.songs); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672adafbaa37a6cef886f7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672adafbaa37a6cef886f7.md index f5248c514c8..8fd4beace6a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672adafbaa37a6cef886f7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65672adafbaa37a6cef886f7.md @@ -1,8 +1,8 @@ --- id: 65672adafbaa37a6cef886f7 -title: الخطوة 80 +title: Step 83 challengeType: 0 -dashedName: step-80 +dashedName: step-83 --- # --description-- @@ -21,26 +21,26 @@ You can also assign it to a variable: const myText = document.createTextNode("your text") ``` -Use the `createTextNode()` method to create a `Reset Playlist` text, then assign it to a `resetText` constant. +Use the `createTextNode()` method to create a `"Reset Playlist"` text, then assign it to a `resetText` constant. # --hints-- You should not modify the existing `if` statement and its content. ```js -assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\);?\s*.*\s*\}/) +assert.match(code, /if\s*\(\s*userData\?\.songs\.length\s*===\s*0\s*\)\s*\{\s*const\s+resetButton\s*=\s*document\.createElement\(\s*('|")button\1\s*\)\s*;?\s*.*\s*\}/) ``` -You should use `document.createTextNode()` to create a `Reset Playlist` text. +You should use `document.createTextNode()` to create a `"Reset Playlist"` text. ```js -assert.match(code, /document\.createTextNode\(\s*('|")Reset\s+Playlist\1\s*\);?/) +assert.match(code, /document\.createTextNode\(\s*('|")Reset\s+Playlist\1\s*\)\s*;?/) ``` You should assign your created text node to a `resetText` constant. ```js -assert.match(code, /const\s+resetText\s*=\s*document\.createTextNode\(\s*('|")Reset\s+Playlist\1\s*\);?/) +assert.match(code, /const\s+resetText\s*=\s*document\.createTextNode\(\s*('|")Reset\s+Playlist\1\s*\)\s*;?/) ``` # --seed-- @@ -784,17 +784,21 @@ previousButton.addEventListener("click", playPreviousSong); shuffleButton.addEventListener("click", shuffle); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/659b0093d7db5a1a1122b7bd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/659b0093d7db5a1a1122b7bd.md index 196cdfe1c37..8d498fe6c9a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/659b0093d7db5a1a1122b7bd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/659b0093d7db5a1a1122b7bd.md @@ -1,8 +1,8 @@ --- id: 659b0093d7db5a1a1122b7bd -title: الخطوة 42 +title: Step 45 challengeType: 0 -dashedName: step-42 +dashedName: step-45 --- # --description-- @@ -27,7 +27,7 @@ assert.match(code, /const\s+getCurrentSongIndex\s*=\s*\(\s*\)\s*=>(\s*userData\? You should pass in `userData?.currentSong` into the `indexOf()` method. ```js -assert.match(code, /const\s+getCurrentSongIndex\s*=\s*\(\s*\)\s*=>(\s*userData\?\.songs\.indexOf\(\s*userData\?\.currentSong\s*\);?|\s*{\s*return\s+userData\?\.songs\.indexOf\(\s*userData\?\.currentSong\s*\);?\s*})/) +assert.match(code, /const\s+getCurrentSongIndex\s*=\s*\(\s*\)\s*=>(\s*userData\?\.songs\.indexOf\(\s*userData\?\.currentSong\s*\)\s*;?|\s*{\s*return\s+userData\?\.songs\.indexOf\(\s*userData\?\.currentSong\s*\)\s*;?\s*})/) ``` # --seed-- @@ -678,17 +678,21 @@ playButton.addEventListener("click", () => { pauseButton.addEventListener("click", pauseSong); -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } - return 0; -}); + return 0; + }); -renderSongs(userData?.songs); + return userData?.songs; +}; + +renderSongs(sortSongs()); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a608b7e7c75a04ccf0c23c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a608b7e7c75a04ccf0c23c.md index 8bc181eee8f..816952f6fad 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a608b7e7c75a04ccf0c23c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a608b7e7c75a04ccf0c23c.md @@ -1,8 +1,8 @@ --- id: 65a608b7e7c75a04ccf0c23c -title: الخطوة 21 +title: Step 22 challengeType: 0 -dashedName: step-21 +dashedName: step-22 --- # --description-- @@ -16,14 +16,14 @@ const names = ["Tom", "Jessica", "Quincy", "Naomi"]; names.sort() // ["Jessica", "Naomi", "Quincy", "Tom"] ``` -Add the `sort()` method to `userData?.songs`. +Inside your `sortSongs` function, add the `sort()` method to `userData?.songs`. # --hints-- You should add the `sort()` method to `userData?.songs`. ```js -assert.match(code, /userData\?\.songs\.sort\(.*\);?/); +assert.match(code, /userData\?\.songs\.sort\(/); ``` # --seed-- @@ -636,9 +636,11 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; +const sortSongs = () => { --fcc-editable-region-- --fcc-editable-region-- +}; renderSongs(userData?.songs); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a6098a3405f206312e28f5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a6098a3405f206312e28f5.md index 2fc76257785..8498c039cea 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a6098a3405f206312e28f5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a6098a3405f206312e28f5.md @@ -1,8 +1,8 @@ --- id: 65a6098a3405f206312e28f5 -title: الخطوة 22 +title: Step 23 challengeType: 0 -dashedName: step-22 +dashedName: step-23 --- # --description-- @@ -38,7 +38,7 @@ In the next few steps, you will learn what each of those `if` statements is doin You should have an empty callback function `()=>{}` inside your `sort()` method with `a` and `b` for the parameter names. ```js -assert.match(code, /userData\?\.songs\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*{\s*}\s*\);?/); +assert.match(code, /userData\?\.songs\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*{\s*}\s*\)\s*;?/); ``` # --seed-- @@ -651,9 +651,11 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; ---fcc-editable-region-- -userData?.songs.sort(); ---fcc-editable-region-- +const sortSongs = () => { + --fcc-editable-region-- + userData?.songs.sort(); + --fcc-editable-region-- +}; renderSongs(userData?.songs); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a609f6e23f3b06c608fb57.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a609f6e23f3b06c608fb57.md index bb4d4b0ff14..f869322ff7a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a609f6e23f3b06c608fb57.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a609f6e23f3b06c608fb57.md @@ -1,8 +1,8 @@ --- id: 65a609f6e23f3b06c608fb57 -title: الخطوة 23 +title: Step 24 challengeType: 0 -dashedName: step-23 +dashedName: step-24 --- # --description-- @@ -54,7 +54,7 @@ assert.match(code, /if\s*\(\s*a\.title\s*<\s*b\.title\s*\)/); Your `if` statement should return `-1` if `a.title` is less than `b.title`. ```js -assert.match(code, /if\s*\(\s*a\.title\s*<\s*b\.title\s*\)\s*{\s*return\s*-1;?\s*}|if\s*\(\s*a\.title\s*<\s*b\.title\s*\)\s*return\s*-1;?/); +assert.match(code, /if\s*\(\s*a\.title\s*<\s*b\.title\s*\)\s*{\s*return\s*-1\s*;?\s*}|if\s*\(\s*a\.title\s*<\s*b\.title\s*\)\s*return\s*-1\s*;?/); ``` # --seed-- @@ -667,11 +667,13 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; ---fcc-editable-region-- -userData?.songs.sort((a,b) => { +const sortSongs = () => { + --fcc-editable-region-- + userData?.songs.sort((a,b) => { -}); ---fcc-editable-region-- + }); + --fcc-editable-region-- +}; renderSongs(userData?.songs); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60aa3efd8fa079c2d1537.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60aa3efd8fa079c2d1537.md index 8bfda8b19b9..9caa806177f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60aa3efd8fa079c2d1537.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60aa3efd8fa079c2d1537.md @@ -1,8 +1,8 @@ --- id: 65a60aa3efd8fa079c2d1537 -title: الخطوة 24 +title: Step 25 challengeType: 0 -dashedName: step-24 +dashedName: step-25 --- # --description-- @@ -48,7 +48,7 @@ assert.match(code, /if\s*\(\s*a\.title\s*>\s*b\.title\s*\)/); Your `if` statement should return the number `1` if `a.title` is greater than `b.title`. ```js -assert.match(code, /if\s*\(\s*a\.title\s*>\s*b\.title\s*\)\s*{\s*return\s*1;?\s*}|if\s*\(\s*a\.title\s*>\s*b\.title\s*\)\s*return\s*1;?/); +assert.match(code, /if\s*\(\s*a\.title\s*>\s*b\.title\s*\)\s*{\s*return\s*1\s*;?\s*}|if\s*\(\s*a\.title\s*>\s*b\.title\s*\)\s*return\s*1\s*;?/); ``` # --seed-- @@ -660,16 +660,16 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } - - --fcc-editable-region-- - - --fcc-editable-region-- -}); + --fcc-editable-region-- + --fcc-editable-region-- + }); +} renderSongs(userData?.songs); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60b0b8b4f96085ac23463.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60b0b8b4f96085ac23463.md index f0def27d092..c0383cfbecf 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60b0b8b4f96085ac23463.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65a60b0b8b4f96085ac23463.md @@ -1,8 +1,8 @@ --- id: 65a60b0b8b4f96085ac23463 -title: الخطوة 25 +title: Step 26 challengeType: 0 -dashedName: step-25 +dashedName: step-26 --- # --description-- @@ -31,8 +31,6 @@ fruits.sort((a, b) => { Below your `if` statements, return the number `0` to leave the order of the two elements unchanged. -Now you should see the songs in alphabetical order in the playlist. - # --hints-- You should return the number `0` below your `if` statements. @@ -651,19 +649,21 @@ const renderSongs = (array) => { playlistSongs.innerHTML = songsHTML; }; -userData?.songs.sort((a,b) => { - if (a.title < b.title) { - return -1; - } +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } - if (a.title > b.title) { - return 1; - } + if (a.title > b.title) { + return 1; + } ---fcc-editable-region-- + --fcc-editable-region-- ---fcc-editable-region-- -}); + --fcc-editable-region-- + }); +}; renderSongs(userData?.songs); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md new file mode 100644 index 00000000000..3d8f1aee856 --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c64fe6c770a22db893e931.md @@ -0,0 +1,643 @@ +--- +id: 65c64fe6c770a22db893e931 +title: Step 21 +challengeType: 0 +dashedName: step-21 +--- + +# --description-- + +Now that you have the list of songs displayed on the screen, it would be nice to sort them in alphabetical order by title. + +Start by creating an arrow function called `sortSongs`. + +# --hints-- + +You should have a function called `sortSongs`. + +```js +assert.isFunction(sortSongs); +``` + +Your `sortSongs` function should use arrow function syntax. + +```js +assert.match(code, /const\s+sortSongs\s*=\s*\(\s*\)\s*=>\s*{\s*}\s*;?/) +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
+
+
+
+
+
+
+

freeCodeCamp

+
+
+
+
+
+
+
+ song cover art +
+
+
+

+

+
+
+ + + + + +
+
+
+
+
+
+
+
+
+
+

Playlist

+
+
+
+
+
+
    +
    +
    + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
  • + + +
  • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
    +
    +
    +
    +
    +
    +
    +

    freeCodeCamp

    +
    +
    +
    +
    +
    +
    +
    + song cover art +
    +
    +
    +

    +

    +
    +
    + + + + + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    Playlist

    +
    +
    +
    +
    +
    +
      +
      +
      + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
    • + + +
    • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
      +
      +
      +
      +
      +
      +
      +

      freeCodeCamp

      +
      +
      +
      +
      +
      +
      +
      + song cover art +
      +
      +
      +

      +

      +
      +
      + + + + + +
      +
      +
      +
      +
      +
      +
      +
      +
      +
      +

      Playlist

      +
      +
      +
      +
      +
      +
        +
        +
        + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
      • + + +
      • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 46796895689..e8d9399bcf5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index 107bde51d14..f6d60c61c4f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index 1b489fa7d3a..b776d6fd410 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index f24a8374aaf..015939beab5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index e4db931f0b6..ecf561f83f0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index d4b42bf8366..b323c0e0e25 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 3bff818192e..a00ed4ea53e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 814f30d4fec..09871a6cb0c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 008a9991435..d02caad99bf 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index 7db103dc2ab..101b21bda44 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 4595b51c221..3c8e6e946bc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index aae4ce7fd0d..28cfd42c366 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index 6aa4c119878..d4c1756383a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index 0d4588701f1..a69b4a7ffad 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 5506ffdba15..e764cffcf43 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index b599faf9dba..4c6ee1fcbe3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index d80112d1481..46e8509d452 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index 25313e2bd12..e8a0881f0fb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index 29dd1490781..ba8e544ab0f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index 8facf52cefa..ffd48ceda83 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 514d2ed1dc0..b194365d076 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index 3fbe68c504a..d1ad1221585 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index 21610d91f30..3679c0283e8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 96312218f65..9caeca116c9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index b8692bdd19c..01972c8e942 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index 26d8f71af1e..c84d65026ed 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index 7dd3a87d588..fc43dd574e4 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 46e0d3b6e77..30a7dab5c89 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 8f577a30973..3565d5a50ce 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index ae998f38479..bac4468c2b3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index 2f05c9374c2..0a36d484bcf 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index 40323c9fca6..e0689f14eb9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 2eac0d43f00..84c88b33d30 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index ddbc05a3b0e..a286cb3d285 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 67f11330272..e285d970090 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index 7e73e46cae1..9fd0ba0c899 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index ab8e2e7d38a..45cd485ebb0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index 8417ffbb2f8..9f62343d16b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index fcc031e3838..b83cddaf05b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 6ab658cfc75..99d016fc017 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index f3a6ca9150f..554ab6d4a9a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 6e406f6da1e..acb2df4094a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 5ee3d20d48d..11933100ad2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 3fc956850db..e2261b019f6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index 25dbe0da4bb..f5c411ab071 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 51345cd8848..e4db5edb8b6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index 6637a2a75df..f35ac4d4681 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: الخطوة 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 1d10defd290..f290586fdd9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: الخطوة 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index 9666504176c..12cfc0ac73b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: الخطوة 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index a320c496e4c..12fe1c37d51 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: الخطوة 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index 77133c51fa3..b951a3e6536 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: الخطوة 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 968edf8d8d9..4c8d4e75a7d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: الخطوة 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index 5138c2d2f1d..9623313563f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: الخطوة 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 2210b72b356..1e3ad2606b7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: الخطوة 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index ba3c99e2f68..6d5f984a543 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: الخطوة 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index a2047cc1c3b..09a6c46c14b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: الخطوة 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index 4bfcec603f6..33379e677b3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: الخطوة 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index c74029f9740..83a323889a9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: الخطوة 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index c0aa18f6ba9..cac4131d84c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: الخطوة 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 3149013f019..5544f4b3398 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: الخطوة 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 3ea75b2e8ed..5e3a93aee81 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: الخطوة 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index c5d633f63bd..1e5ffcb96ab 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: الخطوة 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index 8b27f010799..d2bd27ec59e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: الخطوة 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 5c0e7aaf3fb..ff528b02d09 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: الخطوة 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 59493d8f54c..1b61fb95bb0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: الخطوة 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 2f5fb971d5c..a09f0d04543 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: الخطوة 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 819e3dc543f..a9c705c8ffc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: الخطوة 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index 7e2f3952e75..ea938883a6d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: الخطوة 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index cd99e914576..7ad19036d5c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: الخطوة 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index b2490813a69..b259524d2d5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: الخطوة 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 64047d3d4ed..fc3853e0f9f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: الخطوة 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index db318ad1cd1..48876b1a321 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: الخطوة 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index de95aa48561..9542bb0ae4b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: الخطوة 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index a8ce522c9e7..8d90b2e7567 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: الخطوة 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index 7d1e121780f..584c0120446 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: الخطوة 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 23db8793bb0..912088799f4 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: الخطوة 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index 2e8f53891b1..d6b340e5910 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: الخطوة 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index bfaea17a0e7..2927aa25e15 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: الخطوة 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 9ab9958afd2..8c47159e369 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: الخطوة 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index fa6f39d67e7..dfa712b747e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: الخطوة 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index d468a6278e0..50bb9396457 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: الخطوة 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 300a72b51fc..1934be67533 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: الخطوة 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index b248f21669c..be95a9ed587 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: الخطوة 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index 1a0f078cb1f..ad46a890b6a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: الخطوة 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index 6409841d92f..0bc62245d07 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: الخطوة 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 9bd3ac4f382..fd5e074f80b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: الخطوة 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index 0ce22ca4b20..39e1709c26b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: الخطوة 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index 10e91825f16..5f6bbcc31bc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: الخطوة 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index d4998446293..18d20539301 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: الخطوة 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 5faa5470ca1..ef1e2ee14af 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: الخطوة 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 25e8d916297..ce28b2e7ee8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: الخطوة 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index 114c64b8af3..7553b5a3bcf 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: الخطوة 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index 4c1b1a8a5c1..f69ae8d55ea 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: الخطوة 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index fa8f7bdd0d0..574dd40d018 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: الخطوة 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index a63c547810a..860719bde4d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: الخطوة 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index f06acd1b323..a8d5e05af40 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: الخطوة 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index dad16bcbaac..a92a271963d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: الخطوة 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index cd066e6fcaa..715d320b1fc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: الخطوة 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index 52534636565..2bbb5741491 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: الخطوة 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index 212fef72ae1..71ddeb1f7d1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: الخطوة 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index 856e7993b59..d36c032c925 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: الخطوة 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index 324b8b11cfa..b2225896955 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: الخطوة 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index 1b971618379..89fc9c774f7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: الخطوة 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index 069407bda25..f56783e00f9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: الخطوة 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 7ec2a2e5ef4..4c086b317ea 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: الخطوة 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 8574bdfef84..f4fd39bde3b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: الخطوة 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 7043a2b7ee3..d263bdf54b3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: الخطوة 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index e8ae59f16ec..303311211d4 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: الخطوة 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index b4cd12f9559..e0e1e7204cc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: الخطوة 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 36d29d58676..545d5ddcd3d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: الخطوة 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index e867b64f6ac..01c426e728d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: الخطوة 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index b58449ec609..8b3cb1b4f83 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: الخطوة 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index 2778af6b09e..d9b122d8549 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: الخطوة 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 94711e66103..0aa52253c4b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: الخطوة 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 24edbc3c1fc..2a72a101773 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: الخطوة 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index a11d8c8849b..f19e076fca6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: الخطوة 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 1da4c8d59b3..dc6d63565b3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: الخطوة 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index d0988b5689a..a68f265ff2d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: الخطوة 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index f15c9b77acd..bf5ba8ab818 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: الخطوة 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 2d84b9b6823..a6b0501236d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: الخطوة 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 2207ff249b4..7efda9045cc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: الخطوة 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 5fa8a9b0d1f..a4531f7b311 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: الخطوة 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 5d74ef2f08c..5874bb8eb4d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: الخطوة 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index f046580e62d..28877ef405a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: الخطوة 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index d0aa449a10c..d7376bb2d78 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: الخطوة 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 1ac17c28aac..7fbf61939fb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: الخطوة 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 7a669ff490f..9c4c2d9490f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: الخطوة 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index f40444c599a..2d4ad2dc17c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: الخطوة 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index b146b837164..882f5359853 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: الخطوة 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 164f05308cb..21101bab723 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: الخطوة 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index a21d04834ef..00176126504 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: الخطوة 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 868ce567c3a..26fa7e4c5ab 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: الخطوة 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index e4a107291f1..1110cb36177 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: الخطوة 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 949821c46c9..0f20baeab9a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: الخطوة 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index 017ca8163ff..d13a7eb5ed3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: الخطوة 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 38f788551d9..6daf63db3d9 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: الخطوة 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index 1a59ce9ab43..9670a73667e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: الخطوة 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index fa43417fe4f..c2f4268dba0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: الخطوة 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index c99b2e227aa..e647743e443 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: الخطوة 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index b998819e1eb..71006ed6e31 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: الخطوة 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index 79b6a46e731..7739d08bdfc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: الخطوة 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 261f8a78490..be957205c33 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: الخطوة 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 395a63604a1..d2904f5090e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: الخطوة 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index 69d5bd3ffac..b5af6d28b69 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: الخطوة 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index aa4addf8c5c..fd993364550 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: الخطوة 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index d4d44efae5c..051e7974e36 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: الخطوة 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 15dc88ea0c2..95438a380ba 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: الخطوة 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 1ae277d194a..f60366890bc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: الخطوة 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
        +

        freeCodeCamp Code Warrior

        +

        + Help the main player navigate to the yellow checkpoints. +

        +

        + Use the keyboard arrows to move the player around. +

        +

        You can also use the spacebar to jump.

        + +
        + +
        +
        + +
        +

        Congrats!

        +

        You reached the last checkpoint.

        +
        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
        +

        freeCodeCamp Code Warrior

        +

        + Help the main player navigate to the yellow checkpoints. +

        +

        + Use the keyboard arrows to move the player around. +

        +

        You can also use the spacebar to jump.

        + +
        + +
        +
        + +
        +

        Congrats!

        +

        You reached the last checkpoint.

        +
        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
        +

        freeCodeCamp Code Warrior

        +

        + Help the main player navigate to the yellow checkpoints. +

        +

        + Use the keyboard arrows to move the player around. +

        +

        You can also use the spacebar to jump.

        + +
        + +
        +
        + +
        +

        Congrats!

        +

        You reached the last checkpoint.

        +
        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
        +

        freeCodeCamp Code Warrior

        +

        + Help the main player navigate to the yellow checkpoints. +

        +

        + Use the keyboard arrows to move the player around. +

        +

        You can also use the spacebar to jump.

        + +
        + +
        +
        + +
        +

        Congrats!

        +

        You reached the last checkpoint.

        +
        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
        +

        freeCodeCamp Code Warrior

        +

        + Help the main player navigate to the yellow checkpoints. +

        +

        + Use the keyboard arrows to move the player around. +

        +

        You can also use the spacebar to jump.

        + +
        + +
        +
        + +
        +

        Congrats!

        +

        You reached the last checkpoint.

        +
        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
        +

        freeCodeCamp Code Warrior

        +

        + Help the main player navigate to the yellow checkpoints. +

        +

        + Use the keyboard arrows to move the player around. +

        +

        You can also use the spacebar to jump.

        + +
        + +
        +
        + +
        +

        Congrats!

        +

        You reached the last checkpoint.

        +
        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 56a3560711d..8c26ddf9db5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index ce54927e369..03782c97230 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 483a2cacd6f..b63bfa3bce3 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 68f22397143..9bfaf1287d6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 23348a854b2..ee8aa8a9922 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index 03dbec1eee8..5bf30cc4576 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index cea3d442a5f..a3161c487ee 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index de83be46cea..280080fec4e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index cb8fb56f3d4..f1e6d84648c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index 39fd5a7a291..c523f7d2283 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

        /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

        Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index dd59ba3efca..2caf45733ff 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

        .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

        Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index bdb77579b36..2d345512f4c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 5b50cf81031..f0b002ea35a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 3d89a6d3638..8b2f7f456cd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 3bf69194078..52e6a258292 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index 65fffda25a8..48cc8deab50 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index cc03d94db6c..b97e79ffa31 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index 19a9fd4bc78..28582dc6490 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index 7069b2a8b3c..6f1f55014c6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

        Title:<\/strong>\s*\$\{title\}<\/p>\s*

        Date:<\/strong>\s*\$\{date\}<\/p>\s*

        Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

        Title:<\/strong>\s*\$\{title\}<\/p>\s*

        Date:<\/strong>\s*\$\{date\}<\/p>\s*

        Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index 5bb1779faff..cd9892e4ec1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index ddf2452e45d..9a5d5684524 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index bdb14e06c1c..9d13c56edab 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 1650d1914f0..388d3550c2a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index 3f53e1613aa..876097268fa 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index 1f774bcddd7..09344b58a16 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index 050c25f1995..b3f9f23c56f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index 30d2571189e..7ea3420202f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index a0721e465fd..8973377c3bb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index b378f423bef..0f569760525 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 5834625e992..d77d7075d01 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 02e780ae9e7..de7c60e38ba 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index 6286f27ba6e..293fec4ff75 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index 0b2020b5e33..2e62016db0a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 5b4f12b94ad..2f9b9b184c8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 1e15251a924..c491670a838 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index c5612900d57..4de37fc494c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 4eb578e0c61..4950b45013f 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index 5721fd6b561..b887b3b8d73 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index e6e4bd28060..b4863d5e974 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 27c7a608f7a..426eda67fc6 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

        .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

        Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index 7e07ad56f02..94587492dd0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index ce6770fefa8..9de576ac2cd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index cabdf6e69a9..8977de66042 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 8b124c14da5..5913f55a11e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index fb3ebe5e4a4..75f153e746d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 0e4b75da88d..c318a656d75 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index f2cb43d70bd..d77ee8fcaa7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index cb28aadf734..83f1f032461 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index cefa99d50ec..05c628153ad 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index b7891fec675..f98a4cf6547 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index e3fd986fff6..087f3799a6e 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 5a0e7668a3c..8d8639b9f32 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 2f8e2809683..3134b543826 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index 781af19cde7..d4fc28150bd 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 72a706b9bc1..b38518f1343 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index b5b5b62153c..550c7a4d151 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index e784039fa60..e3cff67f166 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index 20bb3a27199..392d9ab8cd5 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index eb3e1ae5d17..71ced384b6b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index f52bd0c13d7..2efa9b264c7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 955c329d1df..e362547a2ee 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 4f4368047f1..7926e5b86cc 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index f43636f5568..12f17bb97b7 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 6a6d59bac97..75ab75f3455 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 1bf3378e257..18098d7e076 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index fa8163a9193..a4f1ae4042d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index e4d9a8b5996..b812aec7af1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 28132728e26..d434c240748 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 582f6153678..ad66644f8b8 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index b9f29d47e65..afaa2174cc1 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index 477c4612ed2..030cf089edb 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index 694546c3ade..3f960586eca 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index b7501220d7e..9b85c7d306a 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index 54baf4af7ac..10442ac529b 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index ec07caf06d8..1a7ce60c65d 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 626b5d7d8b7..76523d29af2 100644 --- a/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/arabic/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/arabic/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 165e0d47d48..bbf99ded4e2 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

        Creamy Chocolate Fudge

        - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

        Description

        This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

        This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

        diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 9e8cb82b048..bb400db9442 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 3086ba15b54..d0e0977c8eb 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/arabic/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 587b917ceb3..f1d7c07db28 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ dashedName: html-foundations-question-a يبدو عنصر paragraph كامل كما يلي: -مخطط العنصر +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/arabic/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/arabic/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/arabic/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/arabic/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
      • + + +
      • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
        +
        +
        +
        +
        +
        +
        +

        freeCodeCamp

        +
        +
        +
        +
        +
        +
        +
        + song cover art +
        +
        +
        +

        +

        +
        +
        + + + + + +
        +
        +
        +
        +
        +
        +
        +
        +
        +
        +

        Playlist

        +
        +
        +
        +
        +
        +
          +
          +
          + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
        • + + +
        • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
          +
          +
          +
          +
          +
          +
          +

          freeCodeCamp

          +
          +
          +
          +
          +
          +
          +
          + song cover art +
          +
          +
          +

          +

          +
          +
          + + + + + +
          +
          +
          +
          +
          +
          +
          +
          +
          +
          +

          Playlist

          +
          +
          +
          +
          +
          +
            +
            +
            + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
          • + + +
          • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 333a2b30ad9..7e5195dc2ee 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index 0bd1a45148b..3d6d9ef9298 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index a20d770fb2b..21f3125afa1 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index 95f1cc3fd6b..10f42f2fd06 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 6ebf819a5f1..ed5c84d787f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index b08332d00f0..a64aaef4d4d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 3da872efb58..f9755ac73d5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 56ab6e3a1d3..e14ad6925d1 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 234096a3d01..daf6681dc82 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index be95441c2b2..f6271ecabe9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 68ccb9cb5ab..e37064c5687 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index f5305f135ee..9390594eba2 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index 8ce031bb482..be14cee52f6 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index ce525e923eb..7875fe42f15 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index e8ebffa2ee4..471abb1db3b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 992e1f42f91..15ef9c2bc4b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index db72afb2366..c9bf88a1097 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index c75cc54cb11..efac0084db5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index 7109370746a..d881b588767 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index a806af1e81b..acc9f4582a3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 7dc0c010053..7cc8f3fd40a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index 673d00e209b..8f813467290 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index 115c331c80a..d98a28f701f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index ebe99a09d3a..fd2ef5507ac 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index c121dff8def..ea1458f7083 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index f95a386954e..dc1367ea520 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index b8b6d95b2e5..ae87092290d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index d742fee4a47..376887579e3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index b7a12eed1b3..bfe83fa1276 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index d1f795590f4..c403c6494f5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index a8412a77b98..0f2750b2985 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index d3666f7888d..c7c5ee9b989 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 2130235d45f..c95dee89642 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index 5c715f6c1bc..fe9d7f6cf03 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 241bf48e8c6..7390653f4e5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index 6b75cbfc70c..a2f8bcaaeb5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 284f2399db0..d26b47f2bfc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index e59b70acba1..c349b0c5043 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index 12854155520..c7f659d7ca4 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 6d312a02956..f1936a2cb37 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index a44e802b149..db7ce61a38d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index df695fcdb0c..f884c9ed1eb 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 594908e95b7..1a922383646 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 4c9c5e2278b..fb367381a8a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index b24b45c35ae..26d2fff00ab 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index a2a422c1588..1c0b2df7825 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index 5e3ceab40f3..f35ac4d4681 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: 步驟 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 7dd1c8383b6..f290586fdd9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: 步驟 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index 74381f4ccc6..12cfc0ac73b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: 步驟 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 4e03356dd74..12fe1c37d51 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: 步驟 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index ab8985ceb43..b951a3e6536 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: 第 14 步 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index ee5b387c63a..4c8d4e75a7d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: 步驟15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index fc93520360e..9623313563f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: 步驟 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 8c0000f51cd..1e3ad2606b7 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Step 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 0069ad20e8d..6d5f984a543 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: 步驟 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index 72dad4cf48d..09a6c46c14b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: 步驟 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index a11725c0464..33379e677b3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: 步驟 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 93877f37747..83a323889a9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: 步驟21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 285dcdb2414..cac4131d84c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: 步驟 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index f33c09a9ffd..5544f4b3398 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: 步驟-23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 7833fb7ea54..5e3a93aee81 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: 步驟 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index ba29ad11e76..1e5ffcb96ab 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: 步驟 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index 206ab9f0ae9..d2bd27ec59e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: 步驟 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 4ae2e40648f..ff528b02d09 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: 步驟 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 62579ef9932..1b61fb95bb0 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: 第 28 步 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 0b26df869c2..a09f0d04543 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: 步驟 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 88d5f1a7e07..a9c705c8ffc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: 第 30 步 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index 104e34e5fd4..ea938883a6d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: 步驟 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index 4c702555079..7ad19036d5c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: 步驟 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index 1d611628163..b259524d2d5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: 步驟 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index aa4d080c8d0..fc3853e0f9f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: 步驟 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index 49234c8b68d..48876b1a321 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: 步驟 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 368396a09aa..9542bb0ae4b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: 步驟 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index f20278a8371..8d90b2e7567 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: 步驟 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index de39f54e08f..584c0120446 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: 步驟 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index c945ef82c45..912088799f4 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: 步驟 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index 535aab79bef..d6b340e5910 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: 步驟 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index ca5edb47659..2927aa25e15 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: 步驟 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 425a212426b..8c47159e369 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: 步驟 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 86da1e7128e..dfa712b747e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: 第 43 步 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index a002fb3db88..50bb9396457 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: 步驟 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 2951d6c2b41..1934be67533 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: 步驟 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 98cca86ccb3..be95a9ed587 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: 步驟 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index e9f31b323fc..ad46a890b6a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: 步驟 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index 8763ef93196..0bc62245d07 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: 步驟 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 7e39c80270f..fd5e074f80b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: 步驟 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index ccfdf312747..39e1709c26b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: 步驟 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index 697d6e91a0a..5f6bbcc31bc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: 步驟 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 36d53791f2a..18d20539301 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: 第 52 步 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 7be783ba462..ef1e2ee14af 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: 步驟 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 5d8f5c7f5f8..ce28b2e7ee8 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: 第 54 步 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index d62e32dd943..7553b5a3bcf 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: 步驟 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index a91954e588b..f69ae8d55ea 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: 步驟 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index eb254b1c1ba..574dd40d018 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: 步驟 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index aee505ad1b0..860719bde4d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: 步驟 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 5d31b265ae3..a8d5e05af40 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: 步驟 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index 95632b23c18..a92a271963d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: 步驟 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 6964cffaab0..715d320b1fc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: 步驟 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index f04088faecf..2bbb5741491 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: 步驟 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index 604b72a7929..71ddeb1f7d1 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: 步驟 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index b5358b566bd..d36c032c925 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: 步驟 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index aeef85e621f..b2225896955 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: 步驟 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index 549ac71f342..89fc9c774f7 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: 第 66 步 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index c87b42c67ed..f56783e00f9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: 步驟 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index bce78bfcc21..4c086b317ea 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: 步驟 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 6d1a4c9ab75..f4fd39bde3b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: 步驟 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index e775f82c3aa..d263bdf54b3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: 步驟 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index f1b545426fe..303311211d4 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: 步驟 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 5ad83c7f267..e0e1e7204cc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: 步驟 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 0031855b59e..545d5ddcd3d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: 步驟 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index ce29fc865af..01c426e728d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: 步驟 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index efc1a628c26..8b3cb1b4f83 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: 步驟 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index 31a3bc21c19..d9b122d8549 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: 步驟 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 96c28fbe575..0aa52253c4b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: 步驟 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 94d399a0dac..2a72a101773 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: 步驟 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index b76b52c9bfb..f19e076fca6 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: 步驟 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 4f08104a1ab..dc6d63565b3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: 步驟 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index adef5fe6d39..a68f265ff2d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: 第 81 步 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index e26e24ccf66..bf5ba8ab818 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: 步驟 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index be130e67a42..a6b0501236d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: 步驟 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 1f4ce3d16b9..7efda9045cc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: 步驟 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index aa0e73bc4d9..a4531f7b311 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: 步驟 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 725d8bf691d..5874bb8eb4d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: 步驟 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index e4a3c2c2ed7..28877ef405a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: 步驟 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index f6dd9c6767d..d7376bb2d78 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: 步驟 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 53964c25a52..7fbf61939fb 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: 步驟 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index cbf7bfa57f8..9c4c2d9490f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: 步驟 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index 51fc6d998d6..2d4ad2dc17c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: 步驟 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 9444223dc93..882f5359853 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: 步驟 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 8ea41636052..21101bab723 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: 步驟 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index c78aa036ea1..00176126504 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: 步驟 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 99056ab2b84..26fa7e4c5ab 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: 步驟 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index a6a53b8147f..1110cb36177 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: 步驟 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 0d59a1beefd..0f20baeab9a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: 步驟 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index a65cfccdeee..d13a7eb5ed3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: 步驟 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 56016adda4b..6daf63db3d9 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: 步驟 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index 99fc28444a9..9670a73667e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: 步驟 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 0af6bdff5a4..c2f4268dba0 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: 步驟 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index ba29b465abe..e647743e443 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: 步驟 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index 228e7b84d42..71006ed6e31 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: 步驟 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index 94feec24a0e..7739d08bdfc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: 步驟 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 3593aaf3d14..be957205c33 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: 步驟 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 41e1439ec6e..d2904f5090e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: 步驟 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index 0190e2bbeb4..b5af6d28b69 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: 步驟 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index c77323fc83f..fd993364550 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: 步驟 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index a82f18e6b60..051e7974e36 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: 步驟 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index ac5303f9083..95438a380ba 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: 步驟 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 41e9447d804..f60366890bc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: 步驟 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
            +

            freeCodeCamp Code Warrior

            +

            + Help the main player navigate to the yellow checkpoints. +

            +

            + Use the keyboard arrows to move the player around. +

            +

            You can also use the spacebar to jump.

            + +
            + +
            +
            + +
            +

            Congrats!

            +

            You reached the last checkpoint.

            +
            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
            +

            freeCodeCamp Code Warrior

            +

            + Help the main player navigate to the yellow checkpoints. +

            +

            + Use the keyboard arrows to move the player around. +

            +

            You can also use the spacebar to jump.

            + +
            + +
            +
            + +
            +

            Congrats!

            +

            You reached the last checkpoint.

            +
            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
            +

            freeCodeCamp Code Warrior

            +

            + Help the main player navigate to the yellow checkpoints. +

            +

            + Use the keyboard arrows to move the player around. +

            +

            You can also use the spacebar to jump.

            + +
            + +
            +
            + +
            +

            Congrats!

            +

            You reached the last checkpoint.

            +
            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
            +

            freeCodeCamp Code Warrior

            +

            + Help the main player navigate to the yellow checkpoints. +

            +

            + Use the keyboard arrows to move the player around. +

            +

            You can also use the spacebar to jump.

            + +
            + +
            +
            + +
            +

            Congrats!

            +

            You reached the last checkpoint.

            +
            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
            +

            freeCodeCamp Code Warrior

            +

            + Help the main player navigate to the yellow checkpoints. +

            +

            + Use the keyboard arrows to move the player around. +

            +

            You can also use the spacebar to jump.

            + +
            + +
            +
            + +
            +

            Congrats!

            +

            You reached the last checkpoint.

            +
            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
            +

            freeCodeCamp Code Warrior

            +

            + Help the main player navigate to the yellow checkpoints. +

            +

            + Use the keyboard arrows to move the player around. +

            +

            You can also use the spacebar to jump.

            + +
            + +
            +
            + +
            +

            Congrats!

            +

            You reached the last checkpoint.

            +
            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 081ee6a9de2..5bd67f81625 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index cdf2fc65d3e..999a5265714 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 1ff82e50469..a1d80d422f3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index cb297a7f3f1..cf9aeb27f6d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 1b75e4554e5..443f5f78654 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index 0c6597acbf0..f6c89d953be 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 212a801a209..b6120ac76cc 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index 0d842d8a8f1..814b9dd9dce 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 7ea656a26ea..561369a7979 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index ee3b44b6c9a..27fbe976b5f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

            /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

            Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index 83b3b98358e..ac46f3ea5a5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

            .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

            Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index 8ebc2844d23..146d9fa0653 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index f476bdff634..1f81dccfbdf 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 99152a5146f..2652b053fc3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index aaed7b65279..0a67fcb01e3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index eebe042d9c6..dd4844e9faf 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index 35bfe574d4b..a6ee769cde5 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index 43e8280a8bf..9dd7453862c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index c70c278addc..0ceec5a2b10 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

            Title:<\/strong>\s*\$\{title\}<\/p>\s*

            Date:<\/strong>\s*\$\{date\}<\/p>\s*

            Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

            Title:<\/strong>\s*\$\{title\}<\/p>\s*

            Date:<\/strong>\s*\$\{date\}<\/p>\s*

            Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index 81a292e232e..17636f86afa 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index e5ed33e1ed8..fe21ed86904 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 2890f12eb03..f824a6abce3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 11ceb8abaea..4f323183973 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index 0bd440190ff..0500ae95d5d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index dca3d86ca76..9643819a617 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index 05b57b5b429..97c81852d7e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index 5147097adf6..87fa8a1fce8 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 10c3afc6730..738720add33 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 3a2b07b6a98..70fc7dfa1cb 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 2c5c0b5136d..1b7f769acc1 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 4a456880bfb..b2cdd120c9e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index 4689fab4bb8..165bb8b659f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index aad78d1f885..f94139480fb 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 5593625b0f2..6fa83adb216 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 98834aea6de..2d7342c01a4 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 7bfe47cda60..4493d55d0dd 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 99f7fed7e16..620dcae5a9e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index dfde4a9f386..b58e1e2ca9a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index a2ab37d2834..5758229451d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 7d04cc709c7..1560a9d494a 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

            .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

            Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index 6dfeb79f27e..f18e969e904 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index b420b58daa0..c807f0d0d96 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 5731a54006c..ed899230647 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index cb6a2f07c77..d127026a9c8 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 323e9ec1b71..ec841ae34ef 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 1c5869abe50..735cca7bf71 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 022495d33b4..692c31e0f30 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index b0973b98eef..f4a232085ba 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index 5e0b7f62718..b7999f9a404 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 1ec3bbb39a0..a9b6d910242 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 6396c454185..0290446b537 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 39dc45db82e..b061431ea35 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 02c5934bd60..c7147fff385 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index e09abce12a1..fe20e252772 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index fd8b7ac4513..80576deaa9f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index 4e9e7563942..43f5fb1bfe7 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index d18845dd474..8868c5a765c 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index a01378b63c3..85fae5e8755 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index b83329dae59..1f54fee7249 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 69263b466f2..0548230ef75 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 140c6dcc7a1..752158c5e06 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 133be797213..31a9c97e74e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index be148b60d0b..165871e141f 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index e16d0c19ca5..47cd847cf01 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 54d96d79577..4ba76211b90 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 1ad349af8bd..c941d57d03b 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 68c77844c82..97b09673207 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 70c49744e09..7c16803e260 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 861f1aa2436..3afb3b7356d 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 4a6b57e655a..05cac034aa3 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index be333697463..c7af842e367 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index 30067328ece..037c8ef6353 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index 61cdf6a63db..dfadd7ad0be 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index b7d6e279148..95817266274 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index fa018a25940..a52d29bce77 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 739915ef37b..e7a51e3321e 100644 --- a/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/chinese-traditional/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 165e0d47d48..bbf99ded4e2 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

            Creamy Chocolate Fudge

            - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

            Description

            This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

            This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

            diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 55b00a0ba70..9c28492fd8e 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 7bff0373286..fd75db2ef38 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index cdfa5be2928..6dfceac2c62 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ HTML 頁面上幾乎所有的元素都是在開始和結束 HTML 標籤中包裹 一個完整的段落元素看起來像這樣: -元素圖表 +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --作業-- diff --git a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/chinese-traditional/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
          • + + +
          • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
            +
            +
            +
            +
            +
            +
            +

            freeCodeCamp

            +
            +
            +
            +
            +
            +
            +
            + song cover art +
            +
            +
            +

            +

            +
            +
            + + + + + +
            +
            +
            +
            +
            +
            +
            +
            +
            +
            +

            Playlist

            +
            +
            +
            +
            +
            +
              +
              +
              + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
            • + + +
            • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
              +
              +
              +
              +
              +
              +
              +

              freeCodeCamp

              +
              +
              +
              +
              +
              +
              +
              + song cover art +
              +
              +
              +

              +

              +
              +
              + + + + + +
              +
              +
              +
              +
              +
              +
              +
              +
              +
              +

              Playlist

              +
              +
              +
              +
              +
              +
                +
                +
                + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
              • + + +
              • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 31dfdb556fa..b75fba9f08e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index a4db8992e34..f18a1459e17 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index ef79aaf57ed..8e8f223c082 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index 0f1536d15b2..c8653f4642d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 176980e02a8..acce1841010 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 6fd16487f47..a4d4239da38 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index f3af9050d73..90bbb632493 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 7c2f36a4696..efdf2172103 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 2a4cb7f8283..5a69bfd8c0b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index be95441c2b2..f6271ecabe9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 29f10e2b319..195fa6d205b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index f8fde7a33cf..8f4e225bf78 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index bb1590897fa..aa3edd0a60a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index 125a34a2e51..c6adbf13f81 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 2ce37cc5d52..49e153f4eaf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 992e1f42f91..15ef9c2bc4b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index d4c2f57a2de..e84bd2550e3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index cb65c5bf85c..68bc9b37953 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index d4084b69bad..edb3aba2d03 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index cbd9f0550df..97d803aa7c0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 7276b3e16a5..5f2ec75ea6e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index d6e09d8130e..559308a5f1c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index b3196d30303..2ae954ed800 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index d6e060e8169..99adf791d1b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index c303ed54de9..97fe15760ed 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index f95a386954e..dc1367ea520 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index b8b6d95b2e5..ae87092290d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 5ab5a0a5eea..de98f72b885 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 58f31b0746d..cca1a606c45 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index eadeb0f20c9..c419928ea50 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index a08ab5225b1..bb1039c1de4 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index d3666f7888d..c7c5ee9b989 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 6600d4ee501..d278ee7ec97 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index 356872c0164..a7cef7baade 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index f155baf45a1..7c5561fa47b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index feedc1f3586..5481c9ba89f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index dc043a4d64b..dd5b02728a2 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index ce600947f34..49c889b7d76 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index 4624f26de37..6a69c62179c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 8e1b58d9fe5..91c121a608d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index e4d991cbec5..551ca435996 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 92126731309..81bcd5f035b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index f2ad938c57d..51ff03c30f7 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 475ad0d0157..bb73e02881d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index b24b45c35ae..26d2fff00ab 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 6cdafc61356..afdf92c61d6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index 48bf6d27ab9..f35ac4d4681 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: 步骤 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index dab45b5de09..f290586fdd9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: 步骤 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index cf0585ba86d..12cfc0ac73b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: 步骤 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 6c6ef7e3fd6..12fe1c37d51 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: 步骤 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index ab8985ceb43..b951a3e6536 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: 第 14 步 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index aef13180cf5..4c8d4e75a7d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: 步骤15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index 4279b5ddd6d..9623313563f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: 步骤 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 8c0000f51cd..1e3ad2606b7 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Step 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 1f7f06c6d7d..6d5f984a543 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: 步骤 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index f8a2bc7dd80..09a6c46c14b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: 步骤 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index 6b4cb6ac50b..33379e677b3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: 步骤 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index c510f259f6d..83a323889a9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: 步骤21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 416fd587302..cac4131d84c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: 步骤 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 2016416db7e..5544f4b3398 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: 步骤-23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 062ff617843..5e3a93aee81 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: 步骤 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index c2cb169cb48..1e5ffcb96ab 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: 步骤 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index 51ab86fcdc6..d2bd27ec59e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: 步骤 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 7c7161b2e1a..ff528b02d09 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: 步骤 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 62579ef9932..1b61fb95bb0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: 第 28 步 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 6712b6e690e..a09f0d04543 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: 步骤 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 88d5f1a7e07..a9c705c8ffc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: 第 30 步 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index 9e1572fbb1b..ea938883a6d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: 步骤 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index b9b580db6e7..7ad19036d5c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: 步骤 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index 18cc3aea5ca..b259524d2d5 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: 步骤 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 6539bc08e8c..fc3853e0f9f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: 步骤 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index 8ac3f661ff6..48876b1a321 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: 步骤 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 06e86cc0804..9542bb0ae4b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: 步骤 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index cb8e0f9b345..8d90b2e7567 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: 步骤 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index 872ecd29c82..584c0120446 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: 步骤 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 8724c501f5a..912088799f4 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: 步骤 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index 6539096524c..d6b340e5910 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: 步骤 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 7c9fc59da99..2927aa25e15 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: 步骤 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 31d952cf77d..8c47159e369 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: 步骤 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 86da1e7128e..dfa712b747e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: 第 43 步 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index b88c7ba94c9..50bb9396457 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: 步骤 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 48fa25f339f..1934be67533 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: 步骤 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index b912fce2287..be95a9ed587 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: 步骤 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index 5704fb065c6..ad46a890b6a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: 步骤 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index aa6e93cf365..0bc62245d07 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: 步骤 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 6acf8dab2e5..fd5e074f80b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: 步骤 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index 907dfb8cce5..39e1709c26b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: 步骤 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index 97dfd467006..5f6bbcc31bc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: 步骤 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 36d53791f2a..18d20539301 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: 第 52 步 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index a301b41db43..ef1e2ee14af 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: 步骤 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 5d8f5c7f5f8..ce28b2e7ee8 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: 第 54 步 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index 570dbeffde4..7553b5a3bcf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: 步骤 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index 1952e312eaf..f69ae8d55ea 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: 步骤 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index a951ee3e596..574dd40d018 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: 步骤 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index 029e41e01e6..860719bde4d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: 步骤 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 90febd38d2d..a8d5e05af40 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: 步骤 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index 1f2c0a92572..a92a271963d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: 步骤 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 9c0262d855d..715d320b1fc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: 步骤 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index e1a875fe65e..2bbb5741491 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: 步骤 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index c3a3cb98107..71ddeb1f7d1 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: 步骤 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index faf0b5cdbad..d36c032c925 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: 步骤 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index 5ae2466d45c..b2225896955 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: 步骤 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index 549ac71f342..89fc9c774f7 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: 第 66 步 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index df30c5fa7ac..f56783e00f9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: 步骤 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 2ae181fee2c..4c086b317ea 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: 步骤 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index a5515b8d6d0..f4fd39bde3b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: 步骤 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 9331e2c3426..d263bdf54b3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: 步骤 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index 5c8ca7e5bea..303311211d4 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: 步骤 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index f695a8e5b13..e0e1e7204cc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: 步骤 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index af06a161b22..545d5ddcd3d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: 步骤 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 8a4b208e810..01c426e728d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: 步骤 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index 1d8ce22169d..8b3cb1b4f83 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: 步骤 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index 4d3a01d4ae0..d9b122d8549 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: 步骤 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 5bbb8afd88d..0aa52253c4b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: 步骤 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 14d729f01c0..2a72a101773 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: 步骤 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 3d640d22354..f19e076fca6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: 步骤 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 89231b0be69..dc6d63565b3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: 步骤 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index adef5fe6d39..a68f265ff2d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: 第 81 步 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 15ca257ee21..bf5ba8ab818 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: 步骤 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 846b562ebc4..a6b0501236d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: 步骤 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 47636829e61..7efda9045cc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: 步骤 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 24940309f48..a4531f7b311 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: 步骤 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index aab995bd303..5874bb8eb4d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: 步骤 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index 9c4ea2186c3..28877ef405a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: 步骤 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index 1e2ea66ad29..d7376bb2d78 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: 步骤 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 3b449ef0e59..7fbf61939fb 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: 步骤 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 15b317bf233..9c4c2d9490f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: 步骤 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index 0700f6a2b0a..2d4ad2dc17c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: 步骤 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 782f9944942..882f5359853 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: 步骤 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 4e380e905aa..21101bab723 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: 步骤 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 7504a6c418f..00176126504 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: 步骤 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 6ddeb4b1dce..26fa7e4c5ab 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: 步骤 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index 23b75f36146..1110cb36177 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: 步骤 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 421a3f3b0a7..0f20baeab9a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: 步骤 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index afab68a0f2b..d13a7eb5ed3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: 步骤 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index ede388808cf..6daf63db3d9 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: 步骤 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index 6a5bdefa06a..9670a73667e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: 步骤 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 7cabbe736a0..c2f4268dba0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: 步骤 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index 6386d1784a0..e647743e443 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: 步骤 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index 62ae4f16b16..71006ed6e31 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: 步骤 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index 5dadd898ace..7739d08bdfc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: 步骤 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 1d21d4b9da5..be957205c33 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: 步骤 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 95fe5e81387..d2904f5090e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: 步骤 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index 90a06669110..b5af6d28b69 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: 步骤 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index 33f0e078f9e..fd993364550 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: 步骤 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index 25f334520a7..051e7974e36 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: 步骤 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 7694d7e3b46..95438a380ba 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: 步骤 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 1bc62023bbc..f60366890bc 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: 步骤 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                +

                freeCodeCamp Code Warrior

                +

                + Help the main player navigate to the yellow checkpoints. +

                +

                + Use the keyboard arrows to move the player around. +

                +

                You can also use the spacebar to jump.

                + +
                + +
                +
                + +
                +

                Congrats!

                +

                You reached the last checkpoint.

                +
                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                +

                freeCodeCamp Code Warrior

                +

                + Help the main player navigate to the yellow checkpoints. +

                +

                + Use the keyboard arrows to move the player around. +

                +

                You can also use the spacebar to jump.

                + +
                + +
                +
                + +
                +

                Congrats!

                +

                You reached the last checkpoint.

                +
                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                +

                freeCodeCamp Code Warrior

                +

                + Help the main player navigate to the yellow checkpoints. +

                +

                + Use the keyboard arrows to move the player around. +

                +

                You can also use the spacebar to jump.

                + +
                + +
                +
                + +
                +

                Congrats!

                +

                You reached the last checkpoint.

                +
                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                +

                freeCodeCamp Code Warrior

                +

                + Help the main player navigate to the yellow checkpoints. +

                +

                + Use the keyboard arrows to move the player around. +

                +

                You can also use the spacebar to jump.

                + +
                + +
                +
                + +
                +

                Congrats!

                +

                You reached the last checkpoint.

                +
                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                +

                freeCodeCamp Code Warrior

                +

                + Help the main player navigate to the yellow checkpoints. +

                +

                + Use the keyboard arrows to move the player around. +

                +

                You can also use the spacebar to jump.

                + +
                + +
                +
                + +
                +

                Congrats!

                +

                You reached the last checkpoint.

                +
                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                +

                freeCodeCamp Code Warrior

                +

                + Help the main player navigate to the yellow checkpoints. +

                +

                + Use the keyboard arrows to move the player around. +

                +

                You can also use the spacebar to jump.

                + +
                + +
                +
                + +
                +

                Congrats!

                +

                You reached the last checkpoint.

                +
                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index dfb6c598b76..98be02fce1e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 486ec72115b..e64dea76b5d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 8db261344dd..9bc6978e670 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 2762a937b80..16d09104a6d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 69066fae3e0..38b0ba4b9a7 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index 4865369059d..285daaa878d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 192a9671965..6502eb08f66 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index 432bfa8b2b7..22e28b0b1b0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 7ea656a26ea..561369a7979 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index db0587dad47..509dedb0d1b 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index 91737f1ef63..5fdf430f7ee 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index 06d96f081fb..a91e1079f40 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 5f36e0f9c1b..2fcaaa4b4eb 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 7887571bd9d..6a0289f0de6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 851b4284558..7c829a35416 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index eebe042d9c6..dd4844e9faf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index b9c7454b3f2..30e87cb3cdf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index 43e8280a8bf..9dd7453862c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index 91627e103dd..d5c2a3a3cd1 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                Title:<\/strong>\s*\$\{title\}<\/p>\s*

                Date:<\/strong>\s*\$\{date\}<\/p>\s*

                Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                Title:<\/strong>\s*\$\{title\}<\/p>\s*

                Date:<\/strong>\s*\$\{date\}<\/p>\s*

                Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index 4406efab0fd..ec3976b1b96 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 40ef2b08bdc..e7f81435dbe 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 8d257c3b8a5..bca561311a8 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 3d4745ba588..10dd0dd79bf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index 5c385e9ab7a..6b9bfb1e254 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index 6f2118a9610..2b3ed561e56 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index 05b57b5b429..97c81852d7e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index b0f17440df3..5b141b034ba 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index a23050ce8a5..52bf9bb32c8 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 9bccb4add5e..faf8d1a4dd2 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 74c38251c1f..c01874cf940 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 10b7ea41743..8f54e9dd404 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index bd5f67cbbc3..78adcfe55b2 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index aad78d1f885..f94139480fb 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 80856ffb888..ffded166d62 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 98834aea6de..2d7342c01a4 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 3460af410b2..1cf656de587 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 26d2393e4b9..30ee8dc3913 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index be1e5fcb55b..4156dd7c83c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index cf46c73b3e7..6b58fa89755 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index d1eeafe52a2..59599b76588 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index 5398a1a2686..a81942b5db3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index 87dc116bcd8..c85ae3f73ed 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 384aeea04de..3850a18cd41 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 177394949dd..1ce23b1da39 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 72700dc309b..ba6e5fb7adf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 7c6900f9361..860790dceaf 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 028907d2a03..6899c0e2602 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index 70ef0299308..07855efed9e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index cfe31fd9406..4c4ea4ec401 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 6ca556dc59f..86c731c8e15 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 9635d655782..c45dbb4faf3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 39dc45db82e..b061431ea35 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 7f495106f05..99cf8901a86 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index 85dc3980faa..a33a7f0d626 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 44380d46826..e5ef090195f 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index 1f2d61c0127..f4cdd4f7a27 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index db841a569bc..e3dba975397 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index a01378b63c3..85fae5e8755 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index fbbc74152fc..731d9aef8fd 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 05d35c35963..843fda4aec6 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 140c6dcc7a1..752158c5e06 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 79d983e33de..b6967b4eaf0 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 132b306e66d..fe992d5de37 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 8175b5a00dd..db58130ce5e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 54d96d79577..4ba76211b90 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 4441817519f..d53d76273b8 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 7725ad84e27..7dbcb36dd1a 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 9cb69753079..57ba6fee785 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index ea5cac4234a..b712c711ee3 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index c32a4ebab01..1ce73b58cb4 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index e9d11540012..7eab4e85e84 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index 30067328ece..037c8ef6353 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index 3d252a890e7..267b8fd8775 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index b7d6e279148..95817266274 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index c9c06b6ff16..792c1bd255e 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index dd1e1f2224b..6babc162844 100644 --- a/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/chinese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/chinese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 165e0d47d48..bbf99ded4e2 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                Creamy Chocolate Fudge

                - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                Description

                This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 0664362df32..ced53a52afd 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 4897f448f4a..73f7333cdd2 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/chinese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index af621b8f151..3dd44a0c041 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ HTML 页面上几乎所有的元素都是在开始和结束 HTML 标签中包裹 一个完整的段落元素看起来像这样: -元素图表 +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --作业-- diff --git a/curriculum/challenges/chinese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/chinese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/chinese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/chinese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
              • + + +
              • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                +
                +
                +
                +
                +
                +
                +

                freeCodeCamp

                +
                +
                +
                +
                +
                +
                +
                + song cover art +
                +
                +
                +

                +

                +
                +
                + + + + + +
                +
                +
                +
                +
                +
                +
                +
                +
                +
                +

                Playlist

                +
                +
                +
                +
                +
                +
                  +
                  +
                  + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                • + + +
                • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                  +
                  +
                  +
                  +
                  +
                  +
                  +

                  freeCodeCamp

                  +
                  +
                  +
                  +
                  +
                  +
                  +
                  + song cover art +
                  +
                  +
                  +

                  +

                  +
                  +
                  + + + + + +
                  +
                  +
                  +
                  +
                  +
                  +
                  +
                  +
                  +
                  +

                  Playlist

                  +
                  +
                  +
                  +
                  +
                  +
                    +
                    +
                    + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                  • + + +
                  • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 96478bb28d5..a0cb9f01ece 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index bbea82edd9e..ee0b1ceac1e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index 5601be8a1a6..c92a1551b44 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index 4c9764ebc0e..fecc89d50e1 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 2c332dc4ced..29f50cc28dd 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index bee4497b987..8f22b607f7f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index e8e47f50b39..c55680b7470 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 9effc7cfe96..04c0c01a24f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 33a12df4ae6..464728f7f4a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index e0843b30334..41aea3ae219 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index cc9be4ded4f..1680f752014 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 332242163e0..a1c4c40cafa 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index f8eb52f628f..8fd2635a431 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index 903498f8e8c..0fc9cdbe568 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index e046c2d8ef7..bc6532e6c23 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 0e0bb0af961..edbb39a5114 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index ba750061f13..c17ed9e6430 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index 520d3fd25a2..cd0497b6aed 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index 30164df3929..7ef5510077b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index 329cb0a7c90..2fa40c240cc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index d8975dd3ed7..70e54ab3f06 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index a287e20fa7a..ce43359891c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index 7b3e092017f..53084bcabd6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index bbfc57e61d5..f3d1210536d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 34987b9b603..7ece2400398 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index fdb2fbc7f66..5bf78fddba8 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index d076c93f8b1..6aebc1198c9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 7a2c10512d2..ae1ba1fa538 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 4429602149e..9cc215bfc07 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index a69be43048c..713a4e4ca0a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index 27de59631e2..6079c2ea712 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index 082008bca37..1697d5fdc4b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index a4875bda45a..4dea24e4594 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index bfe63b52450..076ab8f31ae 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 2f2c172fe15..2efc504d762 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index 6b2ae2947ad..1c1d866d751 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index f2b7ede61b5..6c841d15d1e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index 6bfe159dc46..3ad434661ee 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index a5a3d8b5c9a..2592a5ca2eb 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index e2f3028da70..fdc1ef6a91f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index a08f2dd2b08..8063834cb66 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 49a588ab5d0..fd64bfd0a3f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 74058fbe180..a0be9343b76 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 393dfb7ce38..2b97410585a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index f65a7a943c0..4a0798e0c56 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 08756488fca..fcd5208598b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index 78a34229bd8..f35ac4d4681 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Paso 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index b61773f4022..f290586fdd9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Paso 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index f95dd1582ec..12cfc0ac73b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Paso 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 33dda2272f2..12fe1c37d51 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Paso 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index 57865697b38..b951a3e6536 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Paso 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 19f32cec47c..4c8d4e75a7d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Paso 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index 6fa5d00d7ab..9623313563f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Paso 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 0608481f762..1e3ad2606b7 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Paso 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 30764e6d988..6d5f984a543 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Paso 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index eb62f6b77ac..09a6c46c14b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Paso 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index 7f3c0e70497..33379e677b3 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Paso 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 4d136b265e8..83a323889a9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Paso 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 0de296dde46..cac4131d84c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Paso 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 10a2ff8cb19..5544f4b3398 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Paso 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index e4a8811ed53..5e3a93aee81 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Paso 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index 9d4d3667cfb..1e5ffcb96ab 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Paso 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index c954f595d6a..d2bd27ec59e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Paso 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index ada5beb0ece..ff528b02d09 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Paso 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 41865159df7..1b61fb95bb0 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Paso 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 6da953f096a..a09f0d04543 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Paso 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 8e0d0053fd1..a9c705c8ffc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Paso 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index 65c55f7ec89..ea938883a6d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Paso 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index 905cb82bba3..7ad19036d5c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Paso 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index ebe78287017..b259524d2d5 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Paso 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index f1f16c0afe2..fc3853e0f9f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Paso 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index 0f6fe3b7716..48876b1a321 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Paso 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 7c14eb70539..9542bb0ae4b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Paso 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 54e6e828c1a..8d90b2e7567 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Paso 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index 12c196f863c..584c0120446 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Paso 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index eb40c47bcfa..912088799f4 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Paso 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index 33c6e9196e4..d6b340e5910 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Paso 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 0e58d76da88..2927aa25e15 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Paso 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index d9048e3e778..8c47159e369 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Paso 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 408d9d13418..dfa712b747e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Paso 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index 6a5aec0271d..50bb9396457 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Paso 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 02b1de22565..1934be67533 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Paso 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 7233302c299..be95a9ed587 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Paso 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index 578bf6ab0dd..ad46a890b6a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Paso 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index 1548c1ca050..0bc62245d07 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Paso 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index d05fa0d3775..fd5e074f80b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Paso 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index f1879914bbb..39e1709c26b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Paso 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index e4dd8b102ac..5f6bbcc31bc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Paso 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 65e3ac224a5..18d20539301 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Paso 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 3a17242ff95..ef1e2ee14af 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Paso 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 858ab6351c6..ce28b2e7ee8 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Paso 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index 221b22e0b4b..7553b5a3bcf 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Paso 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index df2e361033e..f69ae8d55ea 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Paso 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index 5e5f4d2060a..574dd40d018 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Paso 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index 6a62bdbd02c..860719bde4d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Paso 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 93e49e63287..a8d5e05af40 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Paso 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index 692e8559b66..a92a271963d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Paso 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index e708ee3b290..715d320b1fc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Paso 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index 9b09f97ce6a..2bbb5741491 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Paso 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index 16af5670bb1..71ddeb1f7d1 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Paso 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index ac8190a3b69..d36c032c925 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Paso 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index e9a0a9d95eb..b2225896955 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Paso 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index cb17f937441..89fc9c774f7 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Paso 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index 086a6d70ac7..f56783e00f9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Paso 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 2d3ff122d7b..4c086b317ea 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Paso 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 7da3dc06383..f4fd39bde3b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Paso 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 8f444328b18..d263bdf54b3 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Paso 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index 1d19da1e855..303311211d4 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Paso 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 4bce07d1220..e0e1e7204cc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Paso 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index dcb0d55bcd3..545d5ddcd3d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Paso 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 141c8fa2db8..01c426e728d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Paso 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index fd64ea02a32..8b3cb1b4f83 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Paso 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index 59fdf658f3e..d9b122d8549 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Paso 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index d96ec1c8b43..0aa52253c4b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Paso 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index b7f42446ebe..2a72a101773 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Paso 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index c84879f4297..f19e076fca6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Paso 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index dc94a435dac..dc6d63565b3 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Paso 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index dc50532bc13..a68f265ff2d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Paso 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 6bae6e3e1ea..bf5ba8ab818 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Paso 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index d71c1517fb6..a6b0501236d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Paso 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 4b062127853..7efda9045cc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Paso 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index b3531d76f06..a4531f7b311 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Paso 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index ff284da4e97..5874bb8eb4d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Paso 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index ac54dc0e7d3..28877ef405a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Paso 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index 39d8d55526e..d7376bb2d78 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Paso 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 510f53b38d4..7fbf61939fb 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Paso 69 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 2a030ad4b51..9c4c2d9490f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Paso 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index 69cef5303bd..2d4ad2dc17c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Paso 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index f5295cac75f..882f5359853 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Paso 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 25c0cc682ee..21101bab723 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Paso 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index b7e3cdb338e..00176126504 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Paso 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index c1bb381465a..26fa7e4c5ab 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Paso 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index 910205fcf90..1110cb36177 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Paso 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index de17caaba8b..0f20baeab9a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Paso 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index d204d19161c..d13a7eb5ed3 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Paso 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 784acb6f997..6daf63db3d9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Paso 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index dc13408b85f..9670a73667e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Paso 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 1e7eba2f2d2..c2f4268dba0 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Paso 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index 46b8416bd99..e647743e443 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Paso 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index d8b1de143b7..71006ed6e31 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Paso 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index aa6528b8a96..7739d08bdfc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Paso 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 53086d97ee3..be957205c33 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Paso 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 23c8f0672d0..d2904f5090e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Paso 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index ba42e5f1bf8..b5af6d28b69 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Paso 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index abbe7c44d68..fd993364550 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Paso 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index f1bee3d5d5b..051e7974e36 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Paso 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 71fafcee36c..95438a380ba 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Paso 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index d4b892239a5..f60366890bc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Paso 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                    +

                    freeCodeCamp Code Warrior

                    +

                    + Help the main player navigate to the yellow checkpoints. +

                    +

                    + Use the keyboard arrows to move the player around. +

                    +

                    You can also use the spacebar to jump.

                    + +
                    + +
                    +
                    + +
                    +

                    Congrats!

                    +

                    You reached the last checkpoint.

                    +
                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                    +

                    freeCodeCamp Code Warrior

                    +

                    + Help the main player navigate to the yellow checkpoints. +

                    +

                    + Use the keyboard arrows to move the player around. +

                    +

                    You can also use the spacebar to jump.

                    + +
                    + +
                    +
                    + +
                    +

                    Congrats!

                    +

                    You reached the last checkpoint.

                    +
                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                    +

                    freeCodeCamp Code Warrior

                    +

                    + Help the main player navigate to the yellow checkpoints. +

                    +

                    + Use the keyboard arrows to move the player around. +

                    +

                    You can also use the spacebar to jump.

                    + +
                    + +
                    +
                    + +
                    +

                    Congrats!

                    +

                    You reached the last checkpoint.

                    +
                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                    +

                    freeCodeCamp Code Warrior

                    +

                    + Help the main player navigate to the yellow checkpoints. +

                    +

                    + Use the keyboard arrows to move the player around. +

                    +

                    You can also use the spacebar to jump.

                    + +
                    + +
                    +
                    + +
                    +

                    Congrats!

                    +

                    You reached the last checkpoint.

                    +
                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                    +

                    freeCodeCamp Code Warrior

                    +

                    + Help the main player navigate to the yellow checkpoints. +

                    +

                    + Use the keyboard arrows to move the player around. +

                    +

                    You can also use the spacebar to jump.

                    + +
                    + +
                    +
                    + +
                    +

                    Congrats!

                    +

                    You reached the last checkpoint.

                    +
                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                    +

                    freeCodeCamp Code Warrior

                    +

                    + Help the main player navigate to the yellow checkpoints. +

                    +

                    + Use the keyboard arrows to move the player around. +

                    +

                    You can also use the spacebar to jump.

                    + +
                    + +
                    +
                    + +
                    +

                    Congrats!

                    +

                    You reached the last checkpoint.

                    +
                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 047aabdab94..521912826f2 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 130317dfd16..7f583f1b759 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index a7e02a021ad..1c19f7bb938 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index c5aadd39fc7..81037369df0 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 81880e1f730..7aec70f0580 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index 5fd4d1ec092..e715b18e9bf 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 44b12bb1492..1deec73e75b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index 136f6e0e266..8e89b208c6b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index ac7b162ddd9..c57062b01df 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index 2ffa60dd625..e3ca8e5598d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                    /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                    Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index fd97a20a8f9..bace6a01c1f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                    .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                    Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index ccfbc0d5daf..a2b0da0e7cd 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 3b52943b863..062c61f7eff 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index ef33a6aeffb..2ac427452b6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 3189f5ca35a..9378504cb61 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index 03475c19aad..30634c9f955 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index 98e751d3e26..737fd075fec 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index c538687ed0b..042975bfcac 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index a89fd181569..df666b87fe8 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                    Title:<\/strong>\s*\$\{title\}<\/p>\s*

                    Date:<\/strong>\s*\$\{date\}<\/p>\s*

                    Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                    Title:<\/strong>\s*\$\{title\}<\/p>\s*

                    Date:<\/strong>\s*\$\{date\}<\/p>\s*

                    Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index f0a441f3119..622749bc0b6 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 4c4eff1032c..412649336b8 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 0cc69d330fa..9e041b5eb4a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 90155e61757..16e56e0a75a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index 0c4603008f7..1c2074dee9f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index 84a637714b0..e3338b52a52 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index d6da896b076..e61d40ad15d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index c59024fc76a..3b643f26149 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 16a3a05456a..c2098d34491 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 4a3f5ed30f4..52689d87bcc 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index ef68cdb5650..c40d99ae4a9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 92cf30cd64c..0686c645536 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index 2dfecc328f0..ef7249fde90 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index a3341ff495e..23132dda48a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 4e490645262..cfe6a698ebf 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 5501bbb9ba9..5fd7961bf25 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 08b0d3754ac..d60beab807b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 39adf27720a..8f165b3e2c5 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index 9ca0a3a33f0..3638e580058 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index deed518030d..f11699d7242 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 435af4bb791..01d98cbd926 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                    .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                    Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index 21ee1997252..f154b29dc2e 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index fc7439bbccc..0018d4ca470 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 1ff94a40174..751c886ef96 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index fa3e3a0da76..5cb0975f967 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 3e36759b20f..ec44a280b26 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index eff0590b870..4901991c0bf 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index c9ac7d0486c..4d3c7e82440 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index 50b3f5c5ca1..7f00459df16 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index cb0db4f36b3..bd2beddd067 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 235d4cb0973..3be3fd97228 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 9dc2951c119..3d0f48cff11 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 74b535128cd..e443f3f5406 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 1628fd603f3..5e3670212cb 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index 117882d0a22..de9c09ea44f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 28ffd6146ef..7c9cdcf5ad3 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index aa48313ccd8..f634d94a9de 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 9e6d047e677..8daa1a44f9c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index d95e0c08486..c3728b94f99 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index b014cd75b3f..7f39feb1fde 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 5357297d6a0..260afd1e87c 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 656c3a9769c..7bdc9fa731a 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 739a66794e4..b7dee6fd685 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 9be07b69c79..5e2d3a25e8b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index c92e198f2a8..1bde1ab8589 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index d3dac239e98..744e4fb64e9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 7781ee2fb27..bfe8730ee9d 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 65e28df3ccf..9ff7a490be7 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 3ba8eaa61da..b5bf8cb6c62 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 503e0c129eb..bc71cca8751 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 3380060ba90..f82708b223b 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index 260d8b3b594..d242a4ce8f9 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index b3247b00b7d..d8c895544fd 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index 2b8b0065232..51b4908bac4 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index 9d44b378b5b..6b367e9eeb5 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index c139a23549d..8dedce3405f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index ace81a39b28..e6e78f5be8f 100644 --- a/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/espanol/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/espanol/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index df49452bb0c..dc5f82c8d41 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                    Creamy Chocolate Fudge

                    - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                    Description

                    This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                    This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                    diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 6ab4cb1f90e..02bdcd20a2b 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 9ea6a1913b4..f475b5ede38 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/espanol/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index eaefd672883..092d0b4516c 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ Closing tags tell the browser where an element ends. They are almost the same as A full paragraph element looks like this: -element diagram +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --tarea-- diff --git a/curriculum/challenges/espanol/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/espanol/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/espanol/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/espanol/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                  • + + +
                  • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                    +
                    +
                    +
                    +
                    +
                    +
                    +

                    freeCodeCamp

                    +
                    +
                    +
                    +
                    +
                    +
                    +
                    + song cover art +
                    +
                    +
                    +

                    +

                    +
                    +
                    + + + + + +
                    +
                    +
                    +
                    +
                    +
                    +
                    +
                    +
                    +
                    +

                    Playlist

                    +
                    +
                    +
                    +
                    +
                    +
                      +
                      +
                      + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                    • + + +
                    • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                      +
                      +
                      +
                      +
                      +
                      +
                      +

                      freeCodeCamp

                      +
                      +
                      +
                      +
                      +
                      +
                      +
                      + song cover art +
                      +
                      +
                      +

                      +

                      +
                      +
                      + + + + + +
                      +
                      +
                      +
                      +
                      +
                      +
                      +
                      +
                      +
                      +

                      Playlist

                      +
                      +
                      +
                      +
                      +
                      +
                        +
                        +
                        + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                      • + + +
                      • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 60b17b373e3..189a7dd32d4 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Nach deinem `fetch`-Aufruf sollte kein Semikolon stehen. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index b630e0c087b..74b0689c5cb 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Nach deinem `.then()` sollte kein Semikolon stehen. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index acd4f1d3d6a..5902acde75d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index fc61ac28556..53feb326059 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Dein erstes `.then()` sollte kein Semikolon enthalten. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` Du solltest ein weiteres `.then()` mit deinem bestehenden `.then()` verketten. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 1fe97f99e2a..52cff0ad050 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Deine zweite `.then()`-Methode sollte `data` auf der Konsole loggen. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Dein zweites `.then()` sollte kein Semikolon enthalten. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` Du solltest die `.catch()`-Methode mit dem zweiten `.then()` verketten, das du bereits hast. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` Du solltest einen `err`-Parameter zu deiner `.catch()`-Methode hinzufügen. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Deine `.catch()`-Methode sollte eine Arrow-Funktion-Syntax enthalten. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Denke daran, Backticks zu verwenden. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 76a4f6fb788..b7731c52316 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index e73b8568bef..ef7a4590597 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Deine `displayAuthors`-Funktion sollte leer sein. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 25947961316..2ec9cdaaca2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Deine Callback-Funktion sollte leer sein. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index f371d0a07b4..b4d03c9ea0d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) Du solltest eine zusammengesetzte Zuweisung verwenden, um eine leere Template-Literale an das `innerHTML` von `authorContainer` anzuhängen. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index fefe42b512c..76ecdb0fefa 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ Entferne zuerst deine `console.log()`-Anweisung. Weise dann der `authorDataArr`- Du solltest das Konsolenprotokoll entfernen, das `data` anzeigt. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` Du solltest der `authorDataArr`-Variablen `data` zuweisen ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 910baf48bf2..6129eaf607e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the Du solltest der `authorDataArr`-Variablen `data` zuweisen ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` Du solltest ein Konsolen-Protokoll mit dem Text `Author Data Array:` erhalten. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 56d373297ed..1df8537c84d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ Zunächst entferne die Konsolen-Protokoll-Anweisung mit `authorDataArr`. Rufe da Du solltest der `authorDataArr`-Variablen `data` zuweisen ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` Du solltest die Konsolen-Protokoll-Anweisung entfernen, die `authorDataArr` anzeigt ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` Du solltest deine `displayAuthors`-Funktion aufrufen. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) Der zweite Parameter deiner `slice()`-Methode sollte `endingIndex` entsprechen. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index fc89ebe2616..afd9f7ca997 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Setze innerhalb der `fetchMoreAuthors`-Funktion die `startingIndex`- und `ending Du solltest die `startingIndex`-Variable auf `+=8` setzen. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` Du solltest die `endingIndex`-Variable auf `+=8` setzen. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index 8654083b928..3a49ab9e0fa 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Dein Event-Listener sollte `fetchMoreAuthors` als auszuführende Funktion verwenden. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 6cd7633bd7d..6515663c710 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 952d25f300a..f256241f6a7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index a74aa09dabf..f5e3280b999 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index dc798dc087d..88c1980d3e7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Setze innerhalb deines `if`-Blocks `isError` auf `true` und gib `null` zurück. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` Nachdem du `isError` geändert hast, solltest du `return` den Wert `null` geben. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index 24bcb540153..7f2edf98a47 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Deine `if`-Anweisung sollte `return` verwenden, um die Ausführung der Funktion zu beenden. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index a531281c8f5..2ac59c0acde 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 8dd5bfca863..eb54de72f35 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index b4b9c8d581e..29d7e6381f7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index d839f9589a6..047b2f3e5f6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 03f303a231d..abb41b96fad 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index b21105e6978..5d74762ee34 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 814d8615a58..ae316db59f8 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Verwende `Math.ceil()`, um den `middle` Wert aufzurunden. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index b09d1200a10..30c1ceea4a9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Dein `if`-Block sollte leer sein. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 70022de4004..fd04f30575e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ Du wirst noch mehr Übung darin bekommen. Declare a function called `addCharacte You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index fdb2fbc7f66..5bf78fddba8 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index 8362f62bda6..ecfe06cb7d7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ The `.map()` method here will call the `myFunc` function, passing the same argum You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index 3e1e93f8339..355ceb6a410 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Deklariere eine `rangeExpanded`-Variable und weise ihr das Ergebnis des Aufrufs You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 5cfd01c19a3..8ee2bfb2e2b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 67a462a846b..6936b8b2523 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` Du solltest die `.toUpperCase()`-Methode von `match` aufrufen, wenn du sie an `idToText()` übergibst. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index 3f2cf9810f4..6f53e9e9e79 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Deine `highPrecedence`-Funktion sollte leer sein. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 5c8428785d3..a5b6763d550 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ Findet `infixEval` keine Übereinstimmungen, gibt er den `str`-Wert so zurück, Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index b8122250775..9c2ae88bb0f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` Du solltest einen Verweis auf `parseFloat` als Callback an `.map()` übergeben. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index fe72e927a5a..bcd3c82de28 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index c9f258c6047..b101f85181e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` Du solltest der `functionExpanded`-Variablen das Ergebnis des Aufrufs deiner `applyFunction`-Funktion zuweisen. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 5992f59bd86..a23cd62647a 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 684e699ffc7..524ec42b1cc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index 54c2a26dd3f..d54455333c6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 8e6d68599d4..92c710f3737 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index d5ebee8a368..2c1c22aa6dc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index b07fc2db7a4..00c1e1b4f6b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index dc4dfbcd1f2..c0f4e19d134 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index f33d18b6662..1dbb8d808b5 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 400eccf0d2c..38ee5cc9aa3 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index edb235980d2..f8f66f2037d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index c25898e6071..50d9821ad5c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index f0bc81780b5..81ab799839c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 77e7afdb20e..68057055955 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index 201e51dabb0..658b1adca32 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index f4c6be61af1..9c9fa2f6c8b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index f3c376a8aa4..838ec4c93ea 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index 8f51be8d2cc..a20c7be65ea 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 827c645f6cf..9da1bc8c595 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 2458f22b5a7..3da11754c66 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index b62831721a2..ad63f15224c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index 4eba266f706..f886ad0d2a6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index b4b99220693..80f37b457bb 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index b77d3b97c06..f35ac4d4681 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Step 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 03ddec5b50a..f290586fdd9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Step 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index f9092d051ba..12cfc0ac73b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Step 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 177c1e9530f..12fe1c37d51 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Step 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index e4a66ca75b6..b951a3e6536 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Step 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 9568bde8f28..4c8d4e75a7d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Step 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index a517be5aca0..9623313563f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Step 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 8c0000f51cd..1e3ad2606b7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Step 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 59edd2974a4..6d5f984a543 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Step 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index 9e5fbc487db..09a6c46c14b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Step 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index bcdee639238..33379e677b3 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Step 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 1e4a4143139..83a323889a9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Step 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 3e832cbd462..3ca7b28f0f1 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Step 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 9835c452935..5544f4b3398 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Step 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 41c4e61853e..5e3a93aee81 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Step 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index c2acdf72935..1e5ffcb96ab 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Step 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index e508d6e5706..d2bd27ec59e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Step 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 1b8f6b651b4..ff528b02d09 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Step 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 9da49c411c0..1b61fb95bb0 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Step 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 9eda3acb931..a09f0d04543 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Step 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 59f5e533ca4..a9c705c8ffc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Step 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index b8f0e4e2c1d..ea938883a6d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Step 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index b4f3fa00d1a..7ad19036d5c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Step 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index fcf3c262772..b259524d2d5 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Step 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 741c055f1b1..fc3853e0f9f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Step 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index b06d1bf7612..48876b1a321 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Step 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 6a71eaecb91..9542bb0ae4b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Step 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 48be246c1e4..8d90b2e7567 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Step 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index c01f0cea830..584c0120446 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Step 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 6f540ffba9f..912088799f4 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Step 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index a4cec17821d..d6b340e5910 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Step 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 0008d72b607..2927aa25e15 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Step 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 4bd72562aa6..8c47159e369 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Step 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 599eb400ff8..dfa712b747e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Step 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index 1fde2b22720..50bb9396457 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Step 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 1ffe76212d0..1934be67533 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Step 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 40e0ff550b2..be95a9ed587 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Step 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index fbf45229c8b..ad46a890b6a 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Step 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index efb4f904360..0bc62245d07 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Step 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 5a93da5f973..fd5e074f80b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Step 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index c638afa6b92..39e1709c26b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Step 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index c16c37a9119..5f6bbcc31bc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Step 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 8b70856c84a..18d20539301 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Step 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 4fc8800501d..ef1e2ee14af 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Step 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 70130de1347..ce28b2e7ee8 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Step 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index e27db5c4318..7553b5a3bcf 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Step 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index 6d61f54e3b6..f69ae8d55ea 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Step 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index d7598fde8d9..574dd40d018 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Step 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index eaeeaf00e22..860719bde4d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Step 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 4fc4b477f75..a8d5e05af40 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Step 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index fe4ef487def..a92a271963d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Step 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 6a2319095b7..715d320b1fc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Step 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index e8f32580595..2bbb5741491 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Step 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index cbef4344406..71ddeb1f7d1 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Step 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index e2a40e7de0b..d36c032c925 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Step 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index b58b51ae302..b2225896955 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Step 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index fb78953bc72..89fc9c774f7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Step 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index f7360bfc4d9..f56783e00f9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Step 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 930f5809767..4c086b317ea 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Step 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 42fe47de826..f4fd39bde3b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Step 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 871e35007f6..d263bdf54b3 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Step 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index eeb8bc378e4..303311211d4 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Step 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 952978d5c8a..e0e1e7204cc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Step 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 2bc5e567f4f..545d5ddcd3d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Step 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 211e045117d..01c426e728d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Step 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index be8a3ebba64..8b3cb1b4f83 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Step 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index a9de3dcdbd5..d9b122d8549 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Step 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 79eda0fba07..0aa52253c4b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Step 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 4183273e53c..2a72a101773 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Step 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 68b0b517272..f19e076fca6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Step 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 63ce891a2c3..dc6d63565b3 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Step 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index fee261dc90c..a68f265ff2d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Step 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 5ea8e18be2b..bf5ba8ab818 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Step 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 7a67576ffa7..a6b0501236d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Step 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index c8479511f3a..7efda9045cc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Step 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 827bfdf41cc..a4531f7b311 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Step 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 4b2d81c3c67..5874bb8eb4d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Step 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index de760c5496c..18dbbe229c1 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Step 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index afbdc50e5a5..d7376bb2d78 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Step 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 18f8ff7d6d9..7fbf61939fb 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Step 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 7b3ddef9804..9c4c2d9490f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Step 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index ef192444f29..2d4ad2dc17c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Step 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 6ee87a986ef..882f5359853 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Step 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index fe3890964ea..21101bab723 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Step 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 9d5f6830f28..00176126504 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Step 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 1a09fb4ed71..26fa7e4c5ab 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Step 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index ecedd30bbea..1110cb36177 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Step 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 35533919bb2..0f20baeab9a 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Step 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index 12050701935..d13a7eb5ed3 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Step 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 170fa8120b1..6daf63db3d9 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Step 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index df364f0ea8d..9670a73667e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Step 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 8a7964ea682..c2f4268dba0 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Step 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index bd6fca9a403..e647743e443 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Step 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index 373b02e6486..71006ed6e31 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Step 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index c046f2d48c7..7739d08bdfc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Step 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 30b27d5b79c..be957205c33 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Step 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index a5cedbd41d2..d2904f5090e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Step 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index a8833ffbb1c..b5af6d28b69 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Step 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index f7bbbb1edad..fd993364550 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Step 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index f21e554535e..051e7974e36 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Step 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 93460e80702..95438a380ba 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Step 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 7758905840a..f60366890bc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Step 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                        +

                        freeCodeCamp Code Warrior

                        +

                        + Help the main player navigate to the yellow checkpoints. +

                        +

                        + Use the keyboard arrows to move the player around. +

                        +

                        You can also use the spacebar to jump.

                        + +
                        + +
                        +
                        + +
                        +

                        Congrats!

                        +

                        You reached the last checkpoint.

                        +
                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                        +

                        freeCodeCamp Code Warrior

                        +

                        + Help the main player navigate to the yellow checkpoints. +

                        +

                        + Use the keyboard arrows to move the player around. +

                        +

                        You can also use the spacebar to jump.

                        + +
                        + +
                        +
                        + +
                        +

                        Congrats!

                        +

                        You reached the last checkpoint.

                        +
                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                        +

                        freeCodeCamp Code Warrior

                        +

                        + Help the main player navigate to the yellow checkpoints. +

                        +

                        + Use the keyboard arrows to move the player around. +

                        +

                        You can also use the spacebar to jump.

                        + +
                        + +
                        +
                        + +
                        +

                        Congrats!

                        +

                        You reached the last checkpoint.

                        +
                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                        +

                        freeCodeCamp Code Warrior

                        +

                        + Help the main player navigate to the yellow checkpoints. +

                        +

                        + Use the keyboard arrows to move the player around. +

                        +

                        You can also use the spacebar to jump.

                        + +
                        + +
                        +
                        + +
                        +

                        Congrats!

                        +

                        You reached the last checkpoint.

                        +
                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                        +

                        freeCodeCamp Code Warrior

                        +

                        + Help the main player navigate to the yellow checkpoints. +

                        +

                        + Use the keyboard arrows to move the player around. +

                        +

                        You can also use the spacebar to jump.

                        + +
                        + +
                        +
                        + +
                        +

                        Congrats!

                        +

                        You reached the last checkpoint.

                        +
                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                        +

                        freeCodeCamp Code Warrior

                        +

                        + Help the main player navigate to the yellow checkpoints. +

                        +

                        + Use the keyboard arrows to move the player around. +

                        +

                        You can also use the spacebar to jump.

                        + +
                        + +
                        +
                        + +
                        +

                        Congrats!

                        +

                        You reached the last checkpoint.

                        +
                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 1b89942d767..e81968ef58b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- Du solltest `getElementById()` verwenden, um auf das `task-form`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` Du solltest der Variablen `task-form` das `taskForm`-Element zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `confirm-close-dialog`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` Du solltest der Variablen `confirm-close-dialog` das `confirmCloseDialog`-Element zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `open-task-form-btn`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` Du solltest der Variablen `open-task-form-btn` das `openTaskFormBtn`-Element zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 4e5fe287293..fca1aec3004 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y Du solltest `getElementById()` verwenden, um auf das `close-task-form-btn`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` Du solltest das `close-task-form-btn`-Element der Variablen `closeTaskFormBtn` zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `add-or-update-task-btn`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` Du solltest das `add-or-update-task-btn`-Element der Variablen `addOrUpdateTaskBtn` zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `cancel-btn`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` Du solltest das `cancel-btn`-Element der Variablen `cancelBtn` zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index f0f4cdd3c7b..0040c83524b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us Du solltest `getElementById()` verwenden, um auf das `discard-btn`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` Du solltest das `discard-btn`-Element der Variablen `discardBtn` zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `tasks-container`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` Du solltest das `tasks-container`-Element der Variablen `tasksContainer` zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `title-input`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` Du solltest das `title-input`-Element der Variablen `titleInput` zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index c1155d8ee5f..be28a3bac46 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` Du solltest `getElementById()` verwenden, um auf das `date-input`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` Du solltest der `dateInput`-Variablen das `date-input`-Element zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` Du solltest `getElementById()` verwenden, um auf das `description-input`-Element zuzugreifen. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` Du solltest der `descriptionInput`-Variablen das `description-input`-Element zuweisen. Denke daran, `const` zu verwenden, um die Variable zu deklarieren. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index a2aca609fd7..44b869bf03c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index ac7e31fc237..92811341e81 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 80236c3a099..344573b5350 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index e74880ceced..79b369883a2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 7ea656a26ea..561369a7979 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index d36f4df3496..a67e82a4b2f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Erstelle ein `p`-Element und verwende Template-Strings, um seinen Inhalt auf den `title` zu setzen, den du destrukturiert hast. Erstelle genau vor dem Inhalt des `p`-Elements ein `strong`-Element mit dem Text `Title:`. +Erstelle ein `p`-Element und verwende Template-Strings, um seinen Inhalt auf den `title` zu setzen, den du destrukturiert hast. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ Du solltest ein `strong`-Element nach dem öffnenden Tag deines `p`-Elements ers assert.match(code, /

                        /) ``` -Dein `strong`-Element sollte den Text `Title:` enthalten. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                        Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index 8a6b874ed05..0c05b32e2a8 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                        .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                        Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index d7d635454eb..723ad7e4b25 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 6af664aa2fc..0ae5c7ddeca 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 6e048b901d8..b1b0eec3729 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 042959a2328..c7604a1376e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index fc61d5c9993..2091eafbb6f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ Erstelle zunächst innerhalb des `closeTaskFormBtn`-Ereignis-Listeners eine `for Du solltest `const` verwenden, um eine `formInputsContainValues`-Variable mit dem Wert `titleInput.value || dateInput.value || descriptionInput.value;` zu erstellen ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index cacb944bb9b..f3fd46e438b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index ddabb6b5bc0..0035f568837 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index d3e81848f27..afa53435f15 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                        Title:<\/strong>\s*\$\{title\}<\/p>\s*

                        Date:<\/strong>\s*\$\{date\}<\/p>\s*

                        Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                        Title:<\/strong>\s*\$\{title\}<\/p>\s*

                        Date:<\/strong>\s*\$\{date\}<\/p>\s*

                        Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index cdde0d313e1..813cfa3e74f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 9800e032534..84564217ef1 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 8c3c0eddb47..6d7c2381ce3 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 122e656a170..f3fcca0b583 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index ae9af966d03..68386b95688 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index ae05b4d0679..bef9820c65e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index c137f557118..3c803a0ccbb 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index bbb7a8cbbc0..8efe8d178c6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` Du solltest `classList` verwenden, um die Klasse `hidden` im `taskForm` umzuschalten. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 00b33629a9c..8b24f90b8fc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 7de3b9530dd..2050f702423 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 8a88151e92b..4a254280f3e 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 2c0f35591b4..98688ea451b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index ac7c7cabad5..5b13c3885e6 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index ce6f51a8f8c..f491aa46a33 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 93ce50725a4..55b8346ec15 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 896a7555c42..03483529b9f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 09cf466b782..2fe17e17d38 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index a437671b0fb..d6208d688a0 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index b25b91c2457..dfed6c699ed 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index 5b1ffc38ba7..97a3389fc1d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 606a2f3c5c9..bda0b7aae77 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                        .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                        Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index ad4aa30b36f..68ab8873e4f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index 13744209d52..251e4b91cd2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 6a798d41ec3..1de08da1c35 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 5bc52a22de1..4c41766b9b8 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 5ae0d43ad90..27860ec9e37 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 3ffbb7008b6..8e674d31bc1 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index aa618b675c2..ff99891ed17 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index e2fb8f4c223..73a11660860 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index 890ac61c70b..9791b271df7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 06dfdaacfa4..fa64dec1491 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index a6d1e38a3af..56c3a78bdda 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Füge einen neuen `case` für `midfielder` hinzu, der prüft, ob `player.position` `midfielder` entspricht, und zwar nach dem gleichen Muster wie im vorherigen Schritt. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 408d0143a4f..d55b237d719 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index a99f64e7e69..55af8d99d86 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 8d345ab064f..897d5b8b301 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index 4b1981ae7d5..690156756dd 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index f9a8eab7874..4c8c59ea777 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index f29841177de..3590b86d37d 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index ee15d8826e3..7b075f456f7 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index da558fa0d09..c1509021571 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index 5d92e2115ae..cde7db93ebd 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 285342f7590..fb8c4f1bbf2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 06bdc9ff2d2..36caae2f736 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index b08cd859a86..654408b49a2 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index be2f943ada6..09b41ea7f40 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 57c714a7d73..51178fdf750 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 53851040eca..e5c594fbc83 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index a8a85247557..f62c486377a 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 096acb792d7..11a72c0f909 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index dc0b63ca7b4..ad4d028d662 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Deine `if`-Anweisung sollte die Ausführung der Funktion beenden. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index f581bcb94ce..f35ae3f132c 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Deine `isSpam`-Funktion sollte einen einzelnen `msg`-Parameter haben. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Deine `isSpam`-Funktion sollte implizit `false` zurückgeben. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index ce9a62d0351..a8ada9effbc 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index 1bfee08c18e..db09bbeec31 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Benutze `regex` als Parameter für die Callback-Funktion, um für Klarheit zu so Deine `isSpam`-Funktion sollte implizit das Ergebnis von `denyList.some()` zurückgeben. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Dein `.some()`-Callback sollte implizit das Ergebnis des Tests von `msg` auf `regex` zurückgeben. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index c58dd15c858..acf5c4b212b 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index da96053247d..a68528b104f 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index b7d6e279148..95817266274 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index 2df6307a947..d01f5650f13 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 2978be4e3f9..ca418cac637 100644 --- a/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/german/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/german/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/german/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 165e0d47d48..bbf99ded4e2 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/german/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                        Creamy Chocolate Fudge

                        - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                        Description

                        This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                        This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                        diff --git a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index e9328fb62ef..3b889df28b1 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 610eeeae92b..8bd8770ac57 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/german/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/german/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/german/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 32861ac8835..185b29f5c52 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/german/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ Closing tags tell the browser where an element ends. They are almost the same as A full paragraph element looks like this: -element diagram +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/german/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/german/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/german/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/german/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                      • + + +
                      • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                        +
                        +
                        +
                        +
                        +
                        +
                        +

                        freeCodeCamp

                        +
                        +
                        +
                        +
                        +
                        +
                        +
                        + song cover art +
                        +
                        +
                        +

                        +

                        +
                        +
                        + + + + + +
                        +
                        +
                        +
                        +
                        +
                        +
                        +
                        +
                        +
                        +

                        Playlist

                        +
                        +
                        +
                        +
                        +
                        +
                          +
                          +
                          + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                        • + + +
                        • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                          +
                          +
                          +
                          +
                          +
                          +
                          +

                          freeCodeCamp

                          +
                          +
                          +
                          +
                          +
                          +
                          +
                          + song cover art +
                          +
                          +
                          +

                          +

                          +
                          +
                          + + + + + +
                          +
                          +
                          +
                          +
                          +
                          +
                          +
                          +
                          +
                          +

                          Playlist

                          +
                          +
                          +
                          +
                          +
                          +
                            +
                            +
                            + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                          • + + +
                          • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index ad02ca27331..7186358432e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Non dovresti avere un punto e virgola dopo la chiamata di `fetch`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index 483db61f75e..eca6554f4d5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Non dovresti avere un punto e virgola dopo `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index 26fa4d62b88..bac49066df3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ Non dovresti avere un punto e virgola dopo `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index a1be91774c5..3108ed59464 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Il primo `.then()` non dovrebbe avere un punto e virgola. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` Dovresti concatenare un altro metodo `.then()` al `.then()` esistente. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index b5f02cf7704..e6c6139a1b8 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Il secondo metodo `.then()` dovrebbe stampare `data` sulla console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Il secondo `.then()` non dovrebbe avere un punto e virgola. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` Dovresti concatenare il metodo `.catch()` al secondo `.then()` già esistente. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` Dovresti aggiungere un parametro `err` al metodo `.catch()`. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Il metodo `.catch()` dovrebbe usare la sintassi delle funzioni freccia. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Non dimenticate di usare i backtick. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 344e8811596..6836837ac53 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) Dovresti impostare la variabile `startingIndex` a `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` Dovresti usare `let` per dichiarare una variabile chiamata `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) Dovresti impostare la variabile `endingIndex` a `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` Dovresti usare `let` per dichiarare una variabile chiamata `authorDataArr`. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 3c474d904f7..914e252071c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) La funzione `displayAuthors` dovrebbe essere vuota. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 683ee5ce4a8..98fc8b9903b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) La funzione callback dovrebbe essere vuota. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 9e4867c5761..1fbdbba4b33 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) Dovresti usare l'assegnazione composta per aggiungere un template literal vuoto all'`innerHTML` di `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index ccfdda9538b..82735a7ea0c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ Per prima cosa, rimuovi l'istruzione `console.log()`. Poi, assegna `data` alla v Dovresti rimuovere il console log che mostra `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` Dovresti assegnare `data` alla variabile `authorDataArr` ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 8b88c9c8968..c95877cf04e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the Dovresti assegnare `data` alla variabile `authorDataArr` ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` Dovresti avere un console log con il testo `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 105ba4477bf..e8eabe2fde9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ Per prima cosa, rimuovi l'istruzione console log che mostra `authorDataArr`. Poi Dovresti assegnare `data` alla variabile `authorDataArr` ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` Dovresti rimuovere l'istruzione console log che mostra `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` Dovresti chiamare la funzione `displayAuthors`. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) Il secondo parametro del metodo `slice()` dovrebbe essere `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index 6340fbc7747..7900e7702d8 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ All'interno della funzione `fetchMoreAuthors`, imposta le variabili `startingInd Dovresti impostare la variabile `startingIndex` a `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` Dovresti impostare la variabile `endingIndex` a `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index d133d1a81fa..38d31313c89 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) L'event listener dovrebbe prendere `fetchMoreAuthors` come funzione da eseguire. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 135011342f5..90992324041 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ Se questa condizione è soddisfatta, disabilita il pulsante impostando la sua pr Dovresti impostare la proprietà `disabled` di `loadMoreBtn` su `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` Dovresti impostare il `textContent` di `loadMoreBtn` su `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 9a997d85af5..ae8754af2b4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ All'interno di `.catch()`, rimuovi `console.error()` e imposta l'`innerHTML` di Dovresti rimuovere `console.error` e il suo testo. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` Dovresti accedere all'`innerHTML` di `authorContainer` e impostarlo su un elemento `p`. Non dimenticare di racchiudere l'elemento `p` in un template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) L'elemento `p` dovrebbe avere il testo `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index 41e6e302d56..6967c2629cf 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) Dovresti impostare il valore della proprietà `cursor` su `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index 5a72639584c..0bbdf71af2c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Sempre all'interno del blocco `if` imposta `isError` su `true` e restituisci `nu Dopo `alert`, dovresti impostare `isError` su `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` Dopo aver modificato `isError`, dovresti usare `return` per restituire il valore `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index cbfc5e94f62..03fe8f085a9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); L'istruzione `if` dovrebbe usare `return` per terminare l'esecuzione della funzione. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index 0dbfb2a7585..08af3bea136 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ Dovresti assegnare un template literal vuoto alla proprietà `innerHTML` dell'el ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 1c9e25bb51f..a63c0426f83 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Dichiara una funzione `createLabel` annidata utilizzando la sintassi freccia. Do Dovresti dichiarare una variabile `createLabel` nella funzione `onload`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` La variabile `createLabel` dovrebbe essere dichiarata dopo la variabile `container`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` La variabile `createLabel` dovrebbe essere dichiarata con `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` La variabile `createLabel` dovrebbe essere una funzione freccia. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` La funzione `createLabel` dovrebbe avere un parametro `name`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` La funzione `createLabel` dovrebbe essere vuota. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index 1eca4dfdd35..f823d1471a6 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); Dovresti aggiungere il `label` dopo aver impostato gli attributi. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index 2799b9cc4f9..5a8c2f351ca 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); Dovresti passare una funzione callback a `.forEach()` usando la sintassi freccia. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione callback dovrebbe avere `number` come unico parametro. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 6c131e75665..6a5d1f6f059 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Quindi chiama il metodo `.forEach()` sull'array `letters`. Pass an empty callbac Dovresti chiamare la funzione `createLabel()`. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` Dovresti passare `number` alla chiamata `createLabel()`. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` Dovresti chiamare il metodo `.forEach()` sull'array `letters`. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) Dovresti passare al metodo `.forEach()` una funzione callback con la sintassi freccia. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` La funzione callback dovrebbe avere un parametro `letter`. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` La funzione callback dovrebbe essere vuota. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 80df6138971..4ed5e8c665f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); La funzione `sum` dovrebbe utilizzare la sintassi freccia. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione `sum` dovrebbe avere un parametro `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` La funzione `sum` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` La funzione `sum` dovrebbe restituire il risultato della chiamata `.reduce()` su `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` La funzione `sum` dovrebbe restituire la somma di tutti i numeri in `nums`. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index e12c48dd744..9900970986b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); La funzione `isEven` dovrebbe utilizzare la sintassi freccia. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` La funzione `isEven` dovrebbe utilizzare l'operatore di modulo `%`. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index cf1cb59a9e4..90d59b1fd29 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); La funzione `average` dovrebbe utilizzare la sintassi freccia. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione `average` dovrebbe avere un parametro `nums`. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` La funzione `average` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` La funzione `average` dovrebbe restituire il valore medio dell'array `nums`. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b9bbfce2e0d..69347b302b0 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); La funzione `median` dovrebbe avere un parametro `nums`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` La funzione `median` non dovrebbe utilizzare un return implicito. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` La funzione `median` dovrebbe avere una variabile `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` Dovresti usare `const` per dichiarare la variabile `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` Dovresti usare `.slice()` per assegnare una copia dell'array `nums` a `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` Dovresti concatenare il metodo `.sort()` al metodo `.slice()`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` Dovresti passare una funzione callback al metodo `sort` per ordinare accuratamente i numeri in ordine crescente. Usa un return implicito per chiarezza. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index 5465dac989a..d9c82da9223 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n Dovresti assegnare la lunghezza dell'array `sorted` alla variabile `length`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` Dovresti dichiarare una variabile `middle` dopo la variabile `length`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` Dovresti usare `const` per dichiarare la variabile `middle`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` Dovresti assegnare a `middle` il valore della divisione della variabile `length` per `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` Dovresti sottrarre `1` dal calcolo `length / 2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 30145b7f48d..991f31d4963 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Usando la sintassi ternaria, controlla se `length` è pari usando la funzione `i Dovresti usare la parola chiave `return`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` Dovresti chiamare la funzione `isEven()` dopo la parola chiave `return`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` Dovresti passare la variabile `length` alla chiamata `isEven()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` Dovresti usare la sintassi ternaria per controllare la veridicità della chiamata `isEven()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` Se il ternario è truthy, dovresti chiamare la funzione `average()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` Dovresti passare un array alla funzione `average()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` Il primo elemento dell'array passato a `average()` dovrebbe essere l'elemento all'indice `middle` dell'array `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` Il primo elemento dell'array passato a `average()` dovrebbe essere l'elemento all'indice `middle + 1` dell'array `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` Se il ternario è falsy, dovresti restituire il valore di `sorted` all'indice `middle`. Usa `Math.ceil()` per arrotondare per eccesso il valore `middle`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 5fae58c8ac9..749c18cabb5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); La funzione `update` dovrebbe prendere un parametro `event`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` La funzione `update` dovrebbe essere vuota. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 87d7ab97f71..bf358dbbdb5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ La proprietà `target` dell'evento change rappresenta l'elemento che è cambiato Dovresti dichiarare una variabile `element` nella funzione `update`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` Dovresti usare `const` per dichiarare la variabile `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index decb1c0b377..12c177f109a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assegna la proprietà `value` di `element` a una nuova variabile chiamata `value Dovresti dichiarare una variabile `value` dopo la variabile `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` Dovresti usare `const` per dichiarare la variabile `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` Dovresti assegnare la proprietà `value` di `element` alla variabile `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` Dovresti chiamare il metodo `.replace()` sulla proprietà `value` di `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` Dovresti passare al metodo `.replace()` un'espressione regolare che trovi gli spazi. Usa la classe di caratteri `\s`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` Dovresti rendere globale l'espressione regolare. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` Dovresti passare una stringa vuota come secondo argomento al metodo `.replace()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index a0697c988ef..c789cd97e35 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Ora devi controllare se `value` non include l'`id` dell'elemento. Crea una condi Dovresti creare un blocco `if`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` La condizione `if` dovrebbe verificare se `value` include l'`id` di `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Il blocco `if` dovrebbe essere vuoto. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 3c053c0e03c..c4e7056d4fe 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. Puoi usare `[0]`, `.startsWith()` o `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index c705dd107d8..4b7ffea86e6 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s La variabile `idToText` dovrebbe essere una funzione freccia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione `idToText` dovrebbe avere un parametro `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` Dovresti assegnare a `idToText` il risultato della chiamata del metodo `.find()` sull'array `cells`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` Dovresti passare una funzione callback al metodo `.find()`. Usa la sintassi freccia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione callback dovrebbe avere un parametro `cell`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` La funzione callback dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` La funzione callback dovrebbe restituire se `cell.id` è strettamente uguale a `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index a73d70686e3..2412c3f5fa4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ La funzione `idToText` attualmente restituisce un elemento `input`. Aggiornala p Dovresti restituire la proprietà `value` del valore di ritorno del metodo `.find()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 62fa8adee86..d5a0537e935 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Inizia dichiarando una variabile `rangeRegex` e assegnale un'espressione regolar Dovresti dichiarare una variabile `rangeRegex` dopo la funzione `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` Dovresti usare `const` per dichiarare la variabile `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` La variabile `rangeRegex` dovrebbe essere un'espressione regolare. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` `rangeRegex` dovrebbe utilizzare un gruppo di acquisizione. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` `rangeRegex` dovrebbe utilizzare una classe di caratteri nel gruppo di acquisizione. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` `rangeRegex` dovrebbe usare una classe di caratteri per trovare i caratteri da `A` a `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 3bc629113a5..6ad5946e8ca 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Aggiungi un gruppo di acquisizione dopo il gruppo di acquisizione per le lettere Dovresti aggiungere un secondo gruppo di acquisizione a `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Il secondo gruppo di acquisizione dovrebbe avere una classe di caratteri. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Il secondo gruppo di acquisizione dovrebbe avere due classi di caratteri. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` La prima nuova classe di caratteri dovrebbe corrispondere alle cifre da `1` a `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` La seconda classe di caratteri dovrebbe corrispondere alle cifre da `0` a `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` La seconda nuova classe di caratteri dovrebbe essere opzionale. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index 25775ff0f6f..38f86ea33db 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Gli intervalli sono separati da due punti. Dopo i due gruppi di acquisizione, `r Dovresti aggiungere due punti dopo il secondo gruppo di acquisizione. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index aef582f8846..da6863af2e6 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copia i due gruppi di acquisizione esistenti e incollali dopo i due punti. Dovresti aggiungere un terzo gruppo di acquisizione a `rangeRegex`, dopo i due punti. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Il terzo gruppo di acquisizione dovrebbe usare una classe di caratteri. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Il terzo gruppo di acquisizione dovrebbe corrispondere ai caratteri da `A` a `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` Dovresti aggiungere un quarto gruppo di acquisizione a `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Il quarto gruppo di acquisizione dovrebbe corrispondere a una o due cifre. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 097553ccb3b..4a0c6bcb089 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Infine, rendi `rangeRegex` globale e insensibile alle maiuscole. `rangeRegex` dovrebbe essere insensibile alle maiuscole. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` `rangeRegex` dovrebbe essere globale. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` `rangeRegex` dovrebbe essere globale e insensibile alle maiuscole. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index 312d83db1d7..9674c8dd461 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ Per essere sicuro, converti `num1` e `num2` in interi mentre li passi a `range`. Dovresti dichiarare una variabile `rangeFromString` dopo `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` Dovresti usare `const` per dichiarare la variabile `rangeFromString`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` La variabile `rangeFromString` dovrebbe essere una funzione freccia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` La funzione `rangeFromString` dovrebbe avere `num1` come primo parametro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` La funzione `rangeFromString` dovrebbe avere `num2` come secondo parametro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` La funzione `rangeFromString` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` La funzione `rangeFromString` dovrebbe restituire il risultato della chiamata della funzione `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` Dovresti chiamare `parseInt` con `num1` come argomento e passare il risultato alla chiamata di `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` Dovresti chiamare `parseInt` con `num2` come argomento e passare il risultato alla chiamata di `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 9f716da37fb..47e05542166 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Dichiara una funzione `elemValue` che richiede un parametro `num`. La funzione d Dovresti dichiarare una variabile `elemValue` dopo la funzione `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` Dovresti usare `const` per dichiarare la variabile `elemValue`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` La variabile `elemValue` dovrebbe essere una funzione freccia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` La funzione `elemValue` dovrebbe avere `num` come unico parametro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` La funzione `elemValue` dovrebbe essere vuota. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index bcdb9fdfe15..b373698ff2d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Quindi, restituisci la funzione `inner`. Dovresti dichiarare una variabile `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` Dovresti usare `const` per dichiarare la variabile `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` La variabile `inner` dovrebbe essere una funzione freccia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` La funzione `inner` dovrebbe avere `character` come unico parametro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` La funzione `inner` dovrebbe essere vuota. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` Dovresti restituire esplicitamente la funzione `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index f976c5459c8..15de01c6958 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ Nella funzione `inner`, restituisci il risultato della chiamata di `idToText` co La funzione `inner` dovrebbe utilizzare un return esplicito. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` La funzione `inner` dovrebbe restituire il risultato della chiamata della funzione `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` Dovresti passare `character + num` come argomento alla funzione `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 3ee66d3ed30..b0082ae812f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ Farai un po' di pratica su questo aspetto. Dichiara una funzione chiamata `addCh Dovresti dichiarare una variabile `addCharacters`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` Dovresti usare `const` per dichiarare la variabile `addCharacters`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` La variabile `addCharacters` dovrebbe essere una funzione freccia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` La funzione `addCharacters` non dovrebbe usare un return implicito. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` La funzione `addCharacters` dovrebbe avere un parametro `character1`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index 02766bd7b91..104cc375e22 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; La funzione `addCharacters` dovrebbe usare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` La funzione freccia interna dovrebbe essere vuota. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index f360898f1a4..ee0dede90aa 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Anche le funzioni interne possono restituire una funzione. Usando la stessa sint La funzione freccia interna dovrebbe restituire un'altra funzione freccia con un parametro `num`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` La funzione freccia più interna dovrebbe essere vuota. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index 222bb919471..b3c9f788be9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Ora aggiorna la funzione più interna nella catena `addCharacters` per restituir La funzione più interna dovrebbe usare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` La funzione più interna dovrebbe restituire il risultato della chiamata `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` Dovresti passare `character1` come primo argomento alla chiamata `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` Dovresti passare `character2` come secondo argomento alla chiamata `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index cb482c6425e..9e6c8bbec11 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Usa la stessa sintassi della funzione `addCharacters` per aggiornare la funzione La funzione `elemValue` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` La funzione `elemValue` dovrebbe restituire implicitamente una funzione freccia con un parametro `character`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` La funzione freccia interna dovrebbe usare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` La funzione freccia interna dovrebbe restituire il risultato della chiamata `idToText()` con `character + num` come argomento. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index b71e9710e2a..4366507a871 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ La funzione `addCharacters` alla fine restituisce un intervallo di caratteri. Vu Dovresti concatenare il metodo `.map()` alla chiamata `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` Non dovresti passare nulla alla chiamata `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index f48c4f75ac2..cf85bb08cb5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Passa un riferimento alla funzione `elemValue` come callback del metodo `.map()` Non dovresti chiamare la funzione `elemValue`. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` Dovresti passare un riferimento a `elemValue` come callback del metodo `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index cd6d1d3aa65..46f82aca17d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately Dovresti chiamare `elemValue()` nel metodo `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` Dovresti passare `num` alla chiamata `elemValue()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index 09423c05fef..91d0b5d041f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Dichiara una variabile `rangeExpanded` e assegnale il risultato della chiamata d Dovresti dichiarare una variabile `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` Dovresti usare `const` per dichiarare la variabile `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` Dovresti assegnare il risultato della chiamata `.replace()` su `x` alla variabile `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` Dovresti passare `rangeRegex` come argomento a `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index b2c2c4a81e5..6793a96c5f9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ La funzione callback prende alcuni parametri. Il primo è la stringa che dà ris Dovresti passare una funzione freccia come secondo argomento al metodo `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` La funzione freccia dovrebbe prendere un parametro `match`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 99979e14fb6..2cd083d34db 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Dai alla funzione callback altri quattro parametri corrispondenti a quei gruppi Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index ec673af68e7..3accde91b72 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Fai in modo che la callback restituisca implicitamente il risultato della chiama La callback dovrebbe usare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` La callback dovrebbe restituire il risultato della chiamata `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` Dovresti passare `num1` come primo argomento alla chiamata `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` Dovresti passare `num2` come secondo argomento alla chiamata `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 6b1b486cb59..a9689c5393f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Chiama il metodo `.map()` sulla chiamata `rangeFromString()`, passando un riferi Dovresti chiamare il metodo `.map()` sulla chiamata `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` Dovresti passare un riferimento ad `addCharacters` come callback del metodo `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index 9c0bc8da2a2..370b8931e62 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 Dovresti chiamare la funzione `addCharacters()` nel metodo `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` Dovresti passare `char1` come argomento alla chiamata `addCharacters()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index f3b5b1c490e..775776c326c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, Dovresti concatenare una chiamata funzione alla chiamata `addCharacters(char1)`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` Dovresti passare `char2` come argomento alla chiamata di funzione concatenata. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index 9d307683c3c..aed5c7e2276 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefissa il parametro `match` con un trattino basso. Dovresti prefissare il parametro `match` con un trattino basso. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index 6ce593667e1..a98400a3c09 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Dichiara una variabile `cellRegex` corrispondente ai riferimenti delle celle. Do Dovresti dichiarare una variabile `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` Dovresti usare `const` per dichiarare la variabile `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` Dovresti assegnare un'espressione regolare alla variabile `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` L'espressione regolare dovrebbe usare una classe di caratteri per trovare i caratteri da `A` a `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` L'espressione regolare dovrebbe usare una classe di caratteri per trovare le cifre da `1` a `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` L'espressione regolare dovrebbe usare una classe di caratteri per trovare le cifre da `0` a `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` La terza classe di caratteri dovrebbe essere opzionale. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` L'espressione regolare dovrebbe essere insensibile alle maiuscole e globale. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 9dc2f5ebc53..2e95e1b7f99 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Dichiara una variabile `cellExpanded` e assegnale il valore della chiamata `.rep Dovresti dichiarare una variabile `cellExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` Dovresti usare `const` per dichiarare la variabile `cellExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` Dovresti assegnare a `cellExpanded` il risultato della chiamata del metodo `.replace()` su `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` Dovresti passare `cellRegex` come primo argomento alla chiamata `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` Dovresti passare una funzione callback usando la sintassi freccia come secondo argomento alla chiamata `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` La funzione callback dovrebbe avere un parametro `match`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` La funzione callback dovrebbe essere vuota. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 3ee529ac698..d6206614d11 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Aggiorna la funzione callback per restituire il risultato della chiamata `idToTe La funzione callback dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` La funzione callback dovrebbe chiamare `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` Dovresti passare `match` alla chiamata `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` Dovresti chiamare il metodo `.toUpperCase()` su `match` mentre lo passi a `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index 169cd32dc57..d58ad5066ab 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); La funzione `highPrecedence` dovrebbe utilizzare la sintassi freccia. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione `highPrecedence` dovrebbe avere un parametro `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` La funzione `highPrecedence` dovrebbe essere vuota. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index afb7eda45d7..54db99128d0 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Ogni numero, e l'operatore, dovrebbero essere in gruppi di acquisizione separati Dovresti dichiarare una variabile `regex` nella funzione `highPrecedence`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` Dovresti usare `const` per dichiarare la variabile `regex`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` La variabile `regex` dovrebbe essere un'espressione regolare. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` `regex` dovrebbe usare un gruppo di acquisizione. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Il primo gruppo di acquisizione dovrebbe usare una classe di caratteri. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Il primo gruppo di acquisizione dovrebbe trovare qualsiasi cifra o un punto. Usa la classe di caratteri speciale `\d`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Il primo gruppo di acquisizione dovrebbe trovare la classe di caratteri una o più volte. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` `regex` dovrebbe usare un secondo gruppo di acquisizione. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Il secondo gruppo di acquisizione dovrebbe trovare un operatore `*` o `/`. Usa una classe di caratteri nel gruppo di acquisizione. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` `regex` dovrebbe utilizzare un terzo gruppo di acquisizione. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Il terzo gruppo di acquisizione dovrebbe uguale al primo gruppo di acquisizione. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index ada53f44bb0..479bbae205f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Dichiara una variabile `str2` e assegnale il risultato della chiamata di `infixE Dovresti dichiarare una variabile `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` Dovresti usare `const` per dichiarare la variabile `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` Dovresti assegnare a `str2` il risultato della chiamata della funzione `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` Dovresti passare `str` come primo argomento alla chiamata `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` Dovresti passare `regex` come secondo argomento alla chiamata `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index a6ba7e55aa2..dba24e9dd25 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ Se `infixEval` non trova nessuna corrispondenza, restituirà il valore `str` cos Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` Dovresti usare la parola chiave `return` con una condizione per controllare se `str` è uguale a `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` Dovresti usare la sintassi ternaria con l'istruzione `return`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` Se la condizione ternaria è vera, dovresti restituire `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` Se la condizione ternaria è falsa, dovresti restituire il risultato della chiamata `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` Dovresti passare `str2` alla chiamata `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index eedaa60b64c..73719d28e55 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); La funzione `applyFunction` dovrebbe utilizzare la sintassi freccia. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione `applyFunction` dovrebbe avere un parametro `str`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` `applyFunction` dovrebbe essere vuota. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 67a8dcd1f76..8bbd15f30f9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ Per prima cosa devi gestire gli operatori con precedenza più alta. Dichiara una Dovresti dichiarare una variabile `noHigh`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` Dovresti usare `const` per dichiarare la variabile `noHigh`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` Dovresti assegnare a `noHigh` il risultato della chiamata `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` Dovresti passare `str` come argomento alla chiamata `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index 5920f714443..a5064307001 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Dichiara una variabile `infix` e assegnale un'espressione regolare che corrispon Dovresti dichiarare una variabile `infix`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` Dovresti usare `const` per dichiarare la variabile `infix`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` La variabile `infix` dovrebbe essere un'espressione regolare. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` L'espressione regolare `infix` dovrebbe usare un gruppo di acquisizione. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Il primo gruppo di acquisizione dovrebbe usare una classe di caratteri. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Il primo gruppo di acquisizione dovrebbe corrispondere a una o più cifre o punti decimali. Usa la classe di caratteri `\d`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` L'espressione regolare `infix` dovrebbe usare un secondo gruppo di acquisizione. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Il secondo gruppo di acquisizione dovrebbe usare una classe di caratteri. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Il secondo gruppo di acquisizione dovrebbe corrispondere all'operatore `+` o `-`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` L'espressione regolare `infix` dovrebbe usare un terzo gruppo di acquisizione. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Il terzo gruppo di acquisizione dovrebbe uguale al primo gruppo di acquisizione. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 313d72f6ae5..03a00b62cd1 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Dichiara una variabile `str2` e assegnale il risultato della chiamata `infixEval Dovresti dichiarare una variabile `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` Dovresti usare `const` per dichiarare la variabile `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` Dovresti assegnare a `str2` il risultato della chiamata `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` Dovresti passare `noHigh` come primo argomento a `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` Dovresti passare `infix` come secondo argomento a `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index ec4a8cf6b0a..af1495b5842 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Dichiara una variabile `functionCall` e assegnale questa espressione regolare: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` Questa espressione cercherà chiamate di funzioni come `sum(1, 4)`. @@ -16,19 +16,19 @@ Questa espressione cercherà chiamate di funzioni come `sum(1, 4)`. Dovresti dichiarare una variabile `functionCall`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` Dovresti usare `const` per dichiarare la variabile `functionCall`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` Dovresti assegnare a `functionCall` l'espressione regolare fornita. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 728abe3911c..2976c64e2be 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Dichiara una funzione `toNumberList` che richiede un parametro `args` e restituisce il risultato della suddivisione di `args` secondo le virgole e mappa l'array risultante con `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- Dovresti dichiarare una variabile `toNumberList`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` Dovresti usare `const` per dichiarare la variabile `toNumberList`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` La variabile `toNumberList` dovrebbe essere una funzione freccia. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` La funzione `toNumberList` dovrebbe avere un parametro `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` La funzione `toNumberList` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` La funzione `toNumberList` dovrebbe restituire il risultato della chiamata del metodo `.split()` su `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` Dovresti dividere `args` in corrispondenza del carattere `,`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` Dovresti concatenare il metodo `.map()` al metodo `.split()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` Dovresti passare un riferimento a `parseFloat` come callback di `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index e040661a0f6..e63e81da044 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Dichiara una funzione `apply` che prende dei parametri `fn` e `args`. Dovresti dichiarare una variabile `apply`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` Dovresti usare `const` per dichiarare la variabile `apply`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Alla variabile `apply` dovrebbe essere assegnata una funzione freccia. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` La funzione `apply` dovrebbe avere `fn` come primo parametro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` La funzione `apply` dovrebbe avere `args` come secondo parametro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` La funzione `apply` dovrebbe essere vuota. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index d34f4879d79..36362ac9ea5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Ricorda che `fn` potrebbe non essere in minuscolo, quindi dovrai convertirla in La funzione `apply` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` La funzione `apply` dovrebbe accedere all'oggetto `spreadsheetFunctions`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` La funzione `apply` dovrebbe accedere alla proprietà dell'oggetto `spreadsheetFunctions` che corrisponde al valore di `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` La funzione `apply` dovrebbe chiamare il metodo `.toLowerCase()` su `fn` accedendo alla proprietà. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index 3a5c9d18977..f285bfa6ad5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ La funzione `apply` sta restituendo la funzione del foglio di calcolo, ma non la La funzione `apply` dovrebbe chiamare la funzione `spreadsheetFunctions[fn.toLowerCase()]`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` Dovresti passare una chiamata `toNumberList()` alla chiamata `spreadsheetFunctions[fn.toLowerCase()]`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` Dovresti passare `args` alla chiamata `toNumberList()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index a34bacbe7d8..550aeab56f2 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Ora `applyFunction` deve restituire un risultato. Restituisci il risultato della La funzione `applyFunction` dovrebbe restituire il risultato della chiamata del metodo `.replace()` su `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` Dovresti passare `functionCall` come primo argomento alla chiamata `.replace()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` Dovresti passare una funzione freccia vuota come secondo argomento alla chiamata `.replace()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index db352b3df2c..f3c0c117b5e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Ricordati di rendere `fn` in minuscolo. La funzione callback dovrebbe avere `match` come primo parametro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` La funzione callback dovrebbe avere `fn` come secondo parametro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` La funzione callback dovrebbe avere `args` come terzo parametro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` La funzione callback dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` La funzione callback dovrebbe restituire il risultato della chiamata del metodo `.hasOwnProperty()` sull'oggetto `spreadsheetFunctions`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` Dovresti passare `fn` al metodo `hasOwnProperty()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` Dovresti chiamare il metodo `.toLowerCase()` su `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index c3a11bb0e33..16e16ca7f12 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Usa l'operatore ternario per trasformare la chiamata `.hasOwnProperty()` nella c La funzione callback dovrebbe usare la sintassi ternaria. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` Se la condizione ternaria è vera, la funzione callback dovrebbe restituire il risultato della chiamata `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` Dovresti passare `fn` come primo argomento alla chiamata `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` Dovresti passare `args` come secondo argomento alla chiamata `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` Se il ternario è falso, dovresti restituire `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index ec33ca78656..710a3a8e0ee 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Ora puoi iniziare ad applicare la funzione parser alla logica di `evalFormula`. Dovresti dichiarare una variabile `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` Dovresti usare `const` per dichiarare la variabile `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` Dovresti assegnare alla variabile `functionExpanded` il risultato della chiamata della funzione `applyFunction`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` Dovresti passare `cellExpanded` alla chiamata di `applyFunction`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 7702b57b2da..842da4cc139 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Usa un ternario per controllare se `functionExpanded` è uguale alla stringa ori La funzione `evalFormula` dovrebbe utilizzare la parola chiave `return`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` L'istruzione `return` dovrebbe controllare se `functionExpanded` è uguale a `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` L'istruzione `return` dovrebbe utilizzare un operatore ternario. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` Se la condizione ternaria è vera, `evalFormula()` dovrebbe restituire `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` Se la condizione ternaria è falsa, `evalFormula()` dovrebbe restituire il risultato della chiamata `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` Dovresti passare `functionExpanded` come primo argomento alla chiamata `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` Dovresti passare `cells` come secondo argomento alla chiamata `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index 5ddbbed65e3..4cea9bf6c2a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ All'interno dell'istruzione `if`, imposta il `value` di `element` come risultato Dovresti aggiornare la proprietà `value` di `element` nel blocco `if`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` Dovresti assegnare alla proprietà `value` il risultato della chiamata della funzione `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` Non dovresti passare alcun argomento alla chiamata `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 3cb97ab3d0f..c2056c3d82b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ Il primo argomento della chiamata di `evalFormula` deve essere il contenuto dell Dovresti passare `value` come primo argomento alla chiamata `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` Dovresti chiamare il metodo `.slice()` sull'argomento `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` Dovresti passare il numero `1` come argomento alla chiamata `.slice()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index 5f35c4d3a3e..88c3ccd2e8c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ Puoi ottenere rapidamente tutte le celle dalla pagina ottenendo l'elemento `#con Per il secondo parametro della chiamata `evalFormula()` dovresti chiamare il metodo `.getElementById()` dell'oggetto `document`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` Dovresti passare `container` come argomento alla chiamata `.getElementById()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` Dovresti accedere alla proprietà `children` del risultato della chiamata `.getElementById()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index 045147da7ee..d1a91ba390e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Purtroppo, quella proprietà `children` sta restituendo una serie di elementi, c Dovresti inserire `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 25562db63d4..b2098b85ceb 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); La funzione `even` dovrebbe avere un parametro `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` La funzione `even` dovrebbe utilizzare un return implicito. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` La funzione `even` dovrebbe restituire il risultato della chiamata del metodo `.filter()` su `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` Dovresti passare un riferimento alla funzione `isEven()` come callback per il metodo `.filter()`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` La funzione `even` dovrebbe restituire un array di numeri pari. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index 2e6dda297ae..830c8f16e6c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 71e34cca23b..ef6d6ec2985 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 156929d8d42..f1b253a4f26 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index b35aca9a472..0c818c91984 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index a7bf351ed9a..076f2ee1cb6 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index f5d17ae4253..b57385473ac 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index fb6db38a8ac..3c128f54ee8 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index 404ac487b30..8209f6e2c89 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index c6202937f44..52e7196d9c4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 4d90ead7aea..27b412c16dd 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index 2118d0b1b8c..e39b62119b3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index 0e8628f0753..025e3ed252c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index ce744214775..2e4cdf50997 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 0657086cd45..83805a1b70d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index d1ff45d93b8..0b1b9231c5c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 5ab9533c25b..24dbd8382ff 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index ac7d5cb587d..a24612d164f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 9e78fb699e2..c056ee9cc52 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index d05dfbf082d..d4cd7d8d815 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index 7de9930adb4..32f5322e3de 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 85511623913..54c8be2a29e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index a419709eb89..03848ea99b5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 851f7145f98..92e37d9a6f6 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 70ca8e9a749..8f13454d8eb 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 45a31ac9cf7..4e353375ecd 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index ba4c7c89ace..8a252248466 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 86131e4799c..5940b7c1073 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index b77d3b97c06..f35ac4d4681 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Step 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 03ddec5b50a..f290586fdd9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Step 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index f9092d051ba..12cfc0ac73b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Step 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 177c1e9530f..12fe1c37d51 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Step 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index e4a66ca75b6..b951a3e6536 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Step 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 9568bde8f28..4c8d4e75a7d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Step 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index a517be5aca0..9623313563f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Step 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 8c0000f51cd..1e3ad2606b7 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Step 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 59edd2974a4..6d5f984a543 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Step 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index 9e5fbc487db..09a6c46c14b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Step 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index bcdee639238..33379e677b3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Step 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 1e4a4143139..83a323889a9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Step 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 9cd967ab567..cac4131d84c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Step 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 9835c452935..5544f4b3398 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Step 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 41c4e61853e..5e3a93aee81 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Step 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index c2acdf72935..1e5ffcb96ab 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Step 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index e508d6e5706..d2bd27ec59e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Step 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 1b8f6b651b4..ff528b02d09 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Step 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 9da49c411c0..1b61fb95bb0 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Step 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 9eda3acb931..a09f0d04543 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Step 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 59f5e533ca4..a9c705c8ffc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Step 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index b8f0e4e2c1d..ea938883a6d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Step 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index b4f3fa00d1a..7ad19036d5c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Step 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index fcf3c262772..b259524d2d5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Step 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 741c055f1b1..fc3853e0f9f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Step 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index b06d1bf7612..48876b1a321 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Step 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 6a71eaecb91..9542bb0ae4b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Step 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 48be246c1e4..8d90b2e7567 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Step 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index c01f0cea830..584c0120446 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Step 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 6f540ffba9f..912088799f4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Step 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index a4cec17821d..d6b340e5910 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Step 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 0008d72b607..2927aa25e15 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Step 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 4bd72562aa6..8c47159e369 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Step 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 599eb400ff8..dfa712b747e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Step 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index 1fde2b22720..50bb9396457 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Step 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 1ffe76212d0..1934be67533 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Step 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 40e0ff550b2..be95a9ed587 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Step 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index fbf45229c8b..ad46a890b6a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Step 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index efb4f904360..0bc62245d07 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Step 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 5a93da5f973..fd5e074f80b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Step 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index c638afa6b92..39e1709c26b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Step 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index c16c37a9119..5f6bbcc31bc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Step 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 8b70856c84a..18d20539301 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Step 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 4fc8800501d..ef1e2ee14af 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Step 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 70130de1347..ce28b2e7ee8 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Step 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index e27db5c4318..7553b5a3bcf 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Step 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index 6d61f54e3b6..f69ae8d55ea 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Step 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index d7598fde8d9..574dd40d018 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Step 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index eaeeaf00e22..860719bde4d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Step 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 4fc4b477f75..a8d5e05af40 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Step 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index fe4ef487def..a92a271963d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Step 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 6a2319095b7..715d320b1fc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Step 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index e8f32580595..2bbb5741491 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Step 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index cbef4344406..71ddeb1f7d1 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Step 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index e2a40e7de0b..d36c032c925 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Step 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index b58b51ae302..b2225896955 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Step 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index fb78953bc72..89fc9c774f7 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Step 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index f7360bfc4d9..f56783e00f9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Step 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 930f5809767..4c086b317ea 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Step 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 42fe47de826..f4fd39bde3b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Step 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 871e35007f6..d263bdf54b3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Step 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index eeb8bc378e4..303311211d4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Step 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 952978d5c8a..e0e1e7204cc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Step 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 2bc5e567f4f..545d5ddcd3d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Step 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 211e045117d..01c426e728d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Step 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index be8a3ebba64..8b3cb1b4f83 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Step 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index a9de3dcdbd5..d9b122d8549 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Step 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 79eda0fba07..0aa52253c4b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Step 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 4183273e53c..2a72a101773 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Step 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 68b0b517272..f19e076fca6 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Step 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 63ce891a2c3..dc6d63565b3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Step 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index fee261dc90c..a68f265ff2d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Step 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 5ea8e18be2b..bf5ba8ab818 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Step 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 7a67576ffa7..a6b0501236d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Step 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index c8479511f3a..7efda9045cc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Step 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 827bfdf41cc..a4531f7b311 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Step 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 4b2d81c3c67..5874bb8eb4d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Step 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index 3ea22dd84e5..28877ef405a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Step 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index afbdc50e5a5..d7376bb2d78 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Step 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 18f8ff7d6d9..7fbf61939fb 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Step 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 7b3ddef9804..9c4c2d9490f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Step 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index ef192444f29..2d4ad2dc17c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Step 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 6ee87a986ef..882f5359853 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Step 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index fe3890964ea..21101bab723 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Step 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 9d5f6830f28..00176126504 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Step 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 1a09fb4ed71..26fa7e4c5ab 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Step 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index ecedd30bbea..1110cb36177 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Step 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 35533919bb2..0f20baeab9a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Step 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index 12050701935..d13a7eb5ed3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Step 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 170fa8120b1..6daf63db3d9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Step 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index df364f0ea8d..9670a73667e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Step 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 8a7964ea682..c2f4268dba0 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Step 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index bd6fca9a403..e647743e443 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Step 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index 373b02e6486..71006ed6e31 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Step 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index c046f2d48c7..7739d08bdfc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Step 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 30b27d5b79c..be957205c33 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Step 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index a5cedbd41d2..d2904f5090e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Step 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index a8833ffbb1c..b5af6d28b69 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Step 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index f7bbbb1edad..fd993364550 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Step 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index f21e554535e..051e7974e36 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Step 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 93460e80702..95438a380ba 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Step 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 7758905840a..f60366890bc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Step 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                            +

                            freeCodeCamp Code Warrior

                            +

                            + Help the main player navigate to the yellow checkpoints. +

                            +

                            + Use the keyboard arrows to move the player around. +

                            +

                            You can also use the spacebar to jump.

                            + +
                            + +
                            +
                            + +
                            +

                            Congrats!

                            +

                            You reached the last checkpoint.

                            +
                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                            +

                            freeCodeCamp Code Warrior

                            +

                            + Help the main player navigate to the yellow checkpoints. +

                            +

                            + Use the keyboard arrows to move the player around. +

                            +

                            You can also use the spacebar to jump.

                            + +
                            + +
                            +
                            + +
                            +

                            Congrats!

                            +

                            You reached the last checkpoint.

                            +
                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                            +

                            freeCodeCamp Code Warrior

                            +

                            + Help the main player navigate to the yellow checkpoints. +

                            +

                            + Use the keyboard arrows to move the player around. +

                            +

                            You can also use the spacebar to jump.

                            + +
                            + +
                            +
                            + +
                            +

                            Congrats!

                            +

                            You reached the last checkpoint.

                            +
                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                            +

                            freeCodeCamp Code Warrior

                            +

                            + Help the main player navigate to the yellow checkpoints. +

                            +

                            + Use the keyboard arrows to move the player around. +

                            +

                            You can also use the spacebar to jump.

                            + +
                            + +
                            +
                            + +
                            +

                            Congrats!

                            +

                            You reached the last checkpoint.

                            +
                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                            +

                            freeCodeCamp Code Warrior

                            +

                            + Help the main player navigate to the yellow checkpoints. +

                            +

                            + Use the keyboard arrows to move the player around. +

                            +

                            You can also use the spacebar to jump.

                            + +
                            + +
                            +
                            + +
                            +

                            Congrats!

                            +

                            You reached the last checkpoint.

                            +
                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                            +

                            freeCodeCamp Code Warrior

                            +

                            + Help the main player navigate to the yellow checkpoints. +

                            +

                            + Use the keyboard arrows to move the player around. +

                            +

                            You can also use the spacebar to jump.

                            + +
                            + +
                            +
                            + +
                            +

                            Congrats!

                            +

                            You reached the last checkpoint.

                            +
                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 711e173f5d5..033ada62631 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 6fd78b852ca..d99cbf4be8d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 941c82e6291..0701dae2a51 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 50e9360f0c3..226ebec0365 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index f57a75a6b94..c5121378fc5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index cd6767754da..0ab700240bb 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 006d4bb2153..8440ea67b0a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index b998804835e..3864304d933 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 7ea656a26ea..561369a7979 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index f79fe1ac928..1eef9362cf8 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                            /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                            Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index e9cca076298..65d1bacbae7 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                            .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                            Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index d7d635454eb..723ad7e4b25 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 6af664aa2fc..0ae5c7ddeca 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 6e048b901d8..b1b0eec3729 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 042959a2328..c7604a1376e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index 6b6368a8439..bb2cb639107 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index cacb944bb9b..f3fd46e438b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index ddabb6b5bc0..0035f568837 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index d3e81848f27..afa53435f15 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                            Title:<\/strong>\s*\$\{title\}<\/p>\s*

                            Date:<\/strong>\s*\$\{date\}<\/p>\s*

                            Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                            Title:<\/strong>\s*\$\{title\}<\/p>\s*

                            Date:<\/strong>\s*\$\{date\}<\/p>\s*

                            Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index cdde0d313e1..813cfa3e74f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 9800e032534..84564217ef1 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 8c3c0eddb47..6d7c2381ce3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 122e656a170..f3fcca0b583 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index ae9af966d03..68386b95688 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index ae05b4d0679..bef9820c65e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index c137f557118..3c803a0ccbb 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index 66579ac2fde..d2ccda2884b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 00b33629a9c..8b24f90b8fc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 2b2127f2900..8b3076faef0 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 1b0f70d54fa..e2a3bdea38b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 2b3e27954b5..4d3b925dc0e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index d07fecf9884..a23ecec0452 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index 61c813df7b0..1a88c18b540 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 0f286ea628e..363b500d39e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 0300310d9be..ea414a3ee22 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 311ed31c23f..a7e7ce0a055 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index a0d563ea007..55f137ec96e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index d43ca422ab1..ba796775a2e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index 66376b9472b..d258e16d619 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 606a2f3c5c9..bda0b7aae77 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                            .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                            Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index a0ad7091f21..fc2ceb64414 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index a568b38552c..e1267bec517 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In questo progetto creerai un set di figurine di una squadra di calcio e imparerai a usare oggetti annidati, destrutturazione di oggetti, parametri predefiniti, event listener e istruzioni switch. Tutto l'HTML e il CSS per questo progetto ti è già stato fornito. -Inizia accedendo all'`id` chiamato `team`dal documento HTML e salvalo in una variabile dichiarata con `const` chiamata `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Ricorda che puoi usare il metodo `getElementById` per questo. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 42dd14dc739..d271f26afb3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Ora accedi all'`id` chiamato `sport` dal documento HTML e salvalo in una variabile dichiarata con `const` chiamata `typeOfSport`. Sotto questa variabile, assegna l'`id` `year` a una variabile dichiarata con `const` chiamata `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 5d6ead45e79..bffdbe3f82d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Ora accedi all'`id` chiamato `head-coach` dal documento HTML e salvalo in una variabile dichiarata con `const` chiamata `headCoach`. Sotto questa variabile, assegna l'`id` `player-cards` a una variabile dichiarata con `const` chiamata `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 112bf846d36..b1e00277bc9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Crea un'altra variabile con `const` chiamata `playersDropdownList` e assegnale l'`id` `players` usando il metodo `getElementById`. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index e8725dec981..97c320982a4 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -All'interno dell'oggetto `myFavoriteFootballTeam`, aggiungi una nuova proprietà con una chiave chiamata `team` e come valore la stringa `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ L'oggetto `myFavoriteFootballTeam` dovrebbe avere una proprietà `team`. assert.property(myFavoriteFootballTeam, 'team'); ``` -La proprietà `team` dovrebbe essere impostata su `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 370e7e05740..8c41a530a8d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Sotto la proprietà `team`, aggiungi una nuova proprietà con una chiave chiamata `sport` e una stringa con il valore `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index 31f2f0f7fc8..800d8bdbc78 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Sotto la proprietà `isWorldCupWinner`, aggiungi una nuova chiave chiamata `headCoach` con il valore di un oggetto vuoto. All'interno di quest'oggetto, aggiungi una proprietà con la chiave `coachName` e come valore la stringa `Carlos Bilardo`. Sotto questa proprietà, aggiungi un'altra chiave chiamata `matches` con un valore numerico di 7. +Sotto la proprietà `isWorldCupWinner`, aggiungi una nuova chiave chiamata `headCoach` con il valore di un oggetto vuoto. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ L'oggetto `headCoach` dovrebbe avere una proprietà `coachName`. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -La proprietà `coachName` dovrebbe essere impostata su `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index da0465eb79e..39f4cf08b66 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Il nuovo oggetto dovrebbe avere una proprietà `name`. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -La proprietà `name` dovrebbe essere impostata su `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Il nuovo oggetto dovrebbe avere una proprietà `position`. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -La proprietà `position` dovrebbe essere impostata su `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index a8d0f0af0b0..e83d3f20a1d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Il nuovo oggetto dovrebbe avere una proprietà `name`. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -La proprietà `name` dovrebbe essere impostata su `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Il nuovo oggetto dovrebbe avere una proprietà `position`. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -La proprietà `position` dovrebbe essere impostata su `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index e04ad1e925a..68da36cc01f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); Dovresti assegnare `playerCards.innerHTML` ad `arr.map()` usando l'operatore `+=`. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index 8864d1f95db..e10bf6f1fb3 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 All'interno del corpo della funzione callback, dovrai aggiungere i template literal ` `` ` che accoglieranno il contenuto HTML per le figurine. -All'interno dei template literal, aggiungi un `div` vuoto con la classe `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -Dovresti usare i template literal per aggiungere un `div` vuoto con la classe `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index bbe08424628..4d996e7fd84 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 Il prossimo passo è mostrare la parola `(Captain)` accanto al giocatore se è indicato come capitano della squadra. -Proprio accanto all'espressione `${name}`, aggiungi una nuova espressione incorporata. All'interno di quell'espressione, usa un operatore ternario per controllare se `isCaptain` è vero. In caso affermativo, restituisci `(Captain)`, altrimenti restituisci una stringa vuota. +Proprio accanto all'espressione `${name}`, aggiungi una nuova espressione incorporata. All'interno di quell'espressione, usa un operatore ternario per controllare se `isCaptain` è vero. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -Dovresti usare un operatore ternario per verificare se `isCaptain` è vero e restituire `(Captain)` o restituire una stringa vuota. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index 1949b3ca381..102a32daaab 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ Se il ternario è truthy, dovrebbe mostrare il `nickname` del giocatore. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -Se il ternario è falsy, dovrebbe mostrare la stringa `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 010166b2445..e6a1e00afa9 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 Il prossimo passo è creare una funzione che rilevi quando un utente seleziona qualcosa da `playersDropdownList`. -Usa il metodo `.addEventListener()` su `playersDropdownList`. All'interno dell'event listener, passa il tipo di evento `change` e una funzione callback vuota. +Usa il metodo `.addEventListener()` su `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ Dovresti chiamare il metodo `.addEventListener()` sulla variabile `playersDropdo assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -L'event listener dovrebbe essere in ascolto per l'evento `change`. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index 7945eb81bad..7639056a0bc 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 Se l'utente seleziona `Nicknames` dal menu a discesa, desideri filtrare le figurine dei giocatori che hanno un soprannome. -Inizia aggiungendo una clausola `case` per `nickname` nell'istruzione `switch`. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -Dovresti aggiungere una nuova clausola `case` per `nickname` nell'istruzione `switch`. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 5cbccf8931f..38246e3de0f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Ora aggiungi una clausola `case` per `forward`. +Next, add a `case` clause for `"forward"`. All'interno di questa clausola `case`, chiama la funzione `setPlayerCards` con l'argomento `players.filter()`. -All'interno del metodo `filter()` aggiungi una funzione callback con un parametro `player` che verifica se `player.position` è uguale a `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Infine aggiungi un'istruzione `break` sotto la chiamata della funzione `setPlayerCards`. # --hints-- -Dovresti aggiungere una nuova clausola `case` per `forward` nell'istruzione `switch`. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -Nel `case` di `forward`, dovresti chiamare la funzione `setPlayerCards`. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ La callback di `filter()` dovrebbe prendere un parametro `player`. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -La callback di `filter()` dovrebbe restituire implicitamente se `player.position` è `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl Devi aggiungere un'istruzione `break` sotto la chiamata di `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index 9f6576e9ec1..5934670d7a5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Aggiungi un nuovo `case` per `midfielder` che verifica se `player.position` è uguale a `midfielder` seguito dallo stesso modello dello step precedente. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -Dovresti aggiungere una nuova clausola `case` per `midfielder` nell'istruzione `switch`. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -Nel `case` di `midfielder`, dovresti chiamare la funzione `setPlayerCards`. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ La callback di `filter()` dovrebbe prendere un parametro `player`. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -La callback di `filter()` dovrebbe restituire implicitamente se `player.position` è `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s Devi aggiungere un'istruzione `break` sotto la chiamata di `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index 6bb2599fc38..6387324cf3d 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Aggiungi un nuovo `case` per `defender` che verifica se `player.position` è uguale a `defender` seguito dallo stesso modello dello step precedente. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -Dovresti aggiungere una nuova clausola `case` per `defender` nell'istruzione `switch`. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -Nel `case` di `defender`, dovresti chiamare la funzione `setPlayerCards`. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ La callback di `filter()` dovrebbe prendere un parametro `player`. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -La callback di `filter()` dovrebbe restituire implicitamente se `player.position` è `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p Devi aggiungere un'istruzione `break` sotto la chiamata di `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index c97e1791a29..eeb7164e56e 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Aggiungi un nuovo `case` per `goalkeeper` che verifica se `player.position` è uguale a `goalkeeper` seguito dallo stesso modello dello step precedente. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -Dovresti aggiungere una nuova clausola `case` per `goalkeeper` nell'istruzione `switch`. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -Nel `case` di `goalkeeper`, dovresti chiamare la funzione `setPlayerCards`. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ La callback di `filter()` dovrebbe prendere un parametro `player`. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -La callback di `filter()` dovrebbe restituire implicitamente se `player.position` è `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s Devi aggiungere un'istruzione `break` sotto la chiamata di `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 78fad33ad4b..f003b0ff3da 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Sotto la chiamata `setPlayerCards`, aggiungi una dichiarazione `break`. Devi aggiungere un'istruzione `break` sotto la chiamata di `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 79e3ea7f555..13b6404bf58 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 417198b49f7..2127d495c69 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index fedae3d12d0..3b0dc49177c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index f024c0e76be..cbc34986ef5 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 4c8835a63af..55260992c8c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index dca25c5f235..7bf835e2980 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 36c24d4ca35..ffd281ac734 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index 21184d40203..aa1b27b3b8b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index 66df6f684c3..26a74a97b57 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 8fb8316a1e1..3203771112a 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index b072850a5d3..1fabc234744 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index ac9ed2c01f1..d4228908e6c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 2b399edcf8a..f315cc7d46b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 710440a0588..2c0000dfc53 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 3f7887371ff..e4ed7887401 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index cd6abfb5ff8..1e57d6fbc9c 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 1c8d1ea3c62..861ea76c78b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 150657b4953..55ce3567dba 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ L'istruzione `if` dovrebbe terminare l'esecuzione della funzione. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 27167ffaf26..5077e730177 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); Dovresti usare la sintassi freccia per assegnare a `isSpam` una funzione. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La funzione `isSpam` dovrebbe avere un singolo parametro `msg`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` La funzione `isSpam` dovrebbe restituire implicitamente `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 1f3abff7188..b032a211242 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Tornando all'event listener, devi aggiornare il testo dell'elemento `result`. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. Dovresti usare l'operatore di assegnazione per impostare la proprietà `textContent` dell'elemento `result`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` Dovresti usare la sintassi ternaria per controllare la veridicità di `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` L'espressione truthy dell'operatore ternario dovrebbe impostare la proprietà `textContent` dell'elemento `result` su `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` L'espressione falsy dell'operatore ternario dovrebbe impostare la proprietà `textContent` dell'elemento `result` su `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index 1091457b5e0..dcaeb3b282b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Usa `regex` come parametro per la funzione callback, per chiarezza. La funzione `isSpam` dovrebbe restituire implicitamente il risultato di `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Il metodo `.some()` dovrebbe usare la sintassi freccia per la callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` La callback di `.some()` dovrebbe prendere `regex` come parametro. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` La callback di `.some()` dovrebbe restituire implicitamente il risultato del test di `msg` su `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index c58dd15c858..acf5c4b212b 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index da96053247d..a68528b104f 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index b7d6e279148..95817266274 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index 2df6307a947..d01f5650f13 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 2978be4e3f9..ca418cac637 100644 --- a/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/italian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/italian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/italian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index dbe27d5f2b9..071b53b3087 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                            Creamy Chocolate Fudge

                            - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                            Description

                            This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                            This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                            diff --git a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 6ab4cb1f90e..02bdcd20a2b 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 9ea6a1913b4..f475b5ede38 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/italian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/italian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 32861ac8835..185b29f5c52 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ Closing tags tell the browser where an element ends. They are almost the same as A full paragraph element looks like this: -element diagram +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/italian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/italian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/italian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/italian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                          • + + +
                          • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +

                            freeCodeCamp

                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            + song cover art +
                            +
                            +
                            +

                            +

                            +
                            +
                            + + + + + +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +
                            +

                            Playlist

                            +
                            +
                            +
                            +
                            +
                            +
                              +
                              +
                              + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                            • + + +
                            • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                              +
                              +
                              +
                              +
                              +
                              +
                              +

                              freeCodeCamp

                              +
                              +
                              +
                              +
                              +
                              +
                              +
                              + song cover art +
                              +
                              +
                              +

                              +

                              +
                              +
                              + + + + + +
                              +
                              +
                              +
                              +
                              +
                              +
                              +
                              +
                              +
                              +

                              Playlist

                              +
                              +
                              +
                              +
                              +
                              +
                                +
                                +
                                + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                              • + + +
                              • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 74f789f7f64..9a90c8c9771 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index a8ee33e9288..4782f9bda55 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index 547d0c9bd6a..34560899e75 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index 1d78f28f2e2..9d3cc398d38 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index f94c50a366d..cf4f3b3fd9c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 73b77a857df..71690b72723 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 3edbd1019cd..eb2683f23f8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index cbd67637923..f0d3e68b0a1 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 17ea1556aa5..445ceb01f55 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index e42497c75ad..6189ecbc6be 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 58c6fb34389..88167fa9ad4 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 3cafad4cdbc..11581586d1a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index bfcc82f33c1..3df81508d1c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index ef544ee4a02..a80400b7544 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 6aaa29790bc..43114466119 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index e699ab36a6d..a1cb17ffdcc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index 160cf24ddc5..6494e0f4fe3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index 28269086a77..f3d5810a45a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index 3a1fe506059..5a7f7d149a2 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index e8125a7f3a8..e2444921ffb 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 45d09238166..b229db26523 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index bf7d81a7a35..452a67e0a7a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index ee5b7a363f8..1a8ac5c0dd1 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 4567acb5c4f..0bd5378aacb 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 685d62ba96b..521d0b0bb17 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index fdb2fbc7f66..5bf78fddba8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index d076c93f8b1..6aebc1198c9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 6abced53a66..20dc285498d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index bf6c586396b..f858279337e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index b9c78651c00..e1ef832a429 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index ac65121ef4e..0eeac6cfa13 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index 55677fba349..4b271e047e4 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 7b440504a99..26d36c88f6c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index 9fbc34c8d6f..0d1f1907d44 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 9c46845201d..b78f35f8945 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index b2e50e7633e..9084216c38c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 0398e64e464..6e52c1ed655 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index c1efaed4834..dc852b34933 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index 4fa473f4764..024c4a18eaf 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 51d5ccc532d..aa55ebb3dad 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index 1a87c2fce49..cd974be8a10 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index c12b3b0d687..7cec74688ec 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 9450f81ee4c..505f84f377d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 3c220c76ca5..1944479bcca 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index d37dc1190ce..010ccee347a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 1322cde2009..25ef2c41ea2 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index b77d3b97c06..f35ac4d4681 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Step 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 03ddec5b50a..f290586fdd9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Step 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index f9092d051ba..12cfc0ac73b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Step 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 177c1e9530f..12fe1c37d51 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Step 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index e4a66ca75b6..b951a3e6536 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Step 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 9568bde8f28..4c8d4e75a7d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Step 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index a517be5aca0..9623313563f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Step 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 8c0000f51cd..1e3ad2606b7 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Step 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 59edd2974a4..6d5f984a543 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Step 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index 9e5fbc487db..09a6c46c14b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Step 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index bcdee639238..33379e677b3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Step 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 1e4a4143139..83a323889a9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Step 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 9cd967ab567..cac4131d84c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Step 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 9835c452935..5544f4b3398 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Step 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 41c4e61853e..5e3a93aee81 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Step 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index c2acdf72935..1e5ffcb96ab 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Step 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index e508d6e5706..d2bd27ec59e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Step 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 1b8f6b651b4..ff528b02d09 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Step 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 9da49c411c0..1b61fb95bb0 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Step 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 9eda3acb931..a09f0d04543 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Step 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 59f5e533ca4..a9c705c8ffc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Step 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index b8f0e4e2c1d..ea938883a6d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Step 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index b4f3fa00d1a..7ad19036d5c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Step 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index fcf3c262772..b259524d2d5 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Step 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 741c055f1b1..fc3853e0f9f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Step 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index b06d1bf7612..48876b1a321 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Step 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 6a71eaecb91..9542bb0ae4b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Step 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 48be246c1e4..8d90b2e7567 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Step 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index c01f0cea830..584c0120446 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Step 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 6f540ffba9f..912088799f4 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Step 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index a4cec17821d..d6b340e5910 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Step 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 0008d72b607..2927aa25e15 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Step 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 4bd72562aa6..8c47159e369 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Step 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 599eb400ff8..dfa712b747e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Step 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index 1fde2b22720..50bb9396457 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Step 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 1ffe76212d0..1934be67533 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Step 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 40e0ff550b2..be95a9ed587 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Step 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index fbf45229c8b..ad46a890b6a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Step 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index efb4f904360..0bc62245d07 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Step 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 5a93da5f973..fd5e074f80b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Step 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index c638afa6b92..39e1709c26b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Step 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index c16c37a9119..5f6bbcc31bc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Step 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 8b70856c84a..18d20539301 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Step 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 4fc8800501d..ef1e2ee14af 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Step 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 70130de1347..ce28b2e7ee8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Step 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index e27db5c4318..7553b5a3bcf 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Step 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index 6d61f54e3b6..f69ae8d55ea 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Step 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index d7598fde8d9..574dd40d018 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Step 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index eaeeaf00e22..860719bde4d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Step 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 4fc4b477f75..a8d5e05af40 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Step 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index fe4ef487def..a92a271963d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Step 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 6a2319095b7..715d320b1fc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Step 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index e8f32580595..2bbb5741491 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Step 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index cbef4344406..71ddeb1f7d1 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Step 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index e2a40e7de0b..d36c032c925 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Step 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index b58b51ae302..b2225896955 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Step 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index fb78953bc72..89fc9c774f7 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Step 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index f7360bfc4d9..f56783e00f9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Step 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 930f5809767..4c086b317ea 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Step 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 42fe47de826..f4fd39bde3b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Step 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 871e35007f6..d263bdf54b3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Step 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index eeb8bc378e4..303311211d4 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Step 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 952978d5c8a..e0e1e7204cc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Step 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 2bc5e567f4f..545d5ddcd3d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Step 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 211e045117d..01c426e728d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Step 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index be8a3ebba64..8b3cb1b4f83 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Step 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index a9de3dcdbd5..d9b122d8549 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Step 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 79eda0fba07..0aa52253c4b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Step 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 4183273e53c..2a72a101773 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Step 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 68b0b517272..f19e076fca6 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Step 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 63ce891a2c3..dc6d63565b3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Step 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index fee261dc90c..a68f265ff2d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Step 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 5ea8e18be2b..bf5ba8ab818 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Step 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 7a67576ffa7..a6b0501236d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Step 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index c8479511f3a..7efda9045cc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Step 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 827bfdf41cc..a4531f7b311 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Step 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 4b2d81c3c67..5874bb8eb4d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Step 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index 3ea22dd84e5..28877ef405a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Step 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index afbdc50e5a5..d7376bb2d78 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Step 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 18f8ff7d6d9..7fbf61939fb 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Step 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 7b3ddef9804..9c4c2d9490f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Step 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index ef192444f29..2d4ad2dc17c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Step 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 6ee87a986ef..882f5359853 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Step 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index fe3890964ea..21101bab723 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Step 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 9d5f6830f28..00176126504 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Step 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 1a09fb4ed71..26fa7e4c5ab 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Step 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index ecedd30bbea..1110cb36177 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Step 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 35533919bb2..0f20baeab9a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Step 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index 12050701935..d13a7eb5ed3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Step 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 170fa8120b1..6daf63db3d9 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Step 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index df364f0ea8d..9670a73667e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Step 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 8a7964ea682..c2f4268dba0 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Step 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index bd6fca9a403..e647743e443 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Step 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index 373b02e6486..71006ed6e31 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Step 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index c046f2d48c7..7739d08bdfc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Step 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 30b27d5b79c..be957205c33 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Step 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index a5cedbd41d2..d2904f5090e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Step 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index a8833ffbb1c..b5af6d28b69 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Step 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index f7bbbb1edad..fd993364550 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Step 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index f21e554535e..051e7974e36 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Step 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 93460e80702..95438a380ba 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Step 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 7758905840a..f60366890bc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Step 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                +

                                freeCodeCamp Code Warrior

                                +

                                + Help the main player navigate to the yellow checkpoints. +

                                +

                                + Use the keyboard arrows to move the player around. +

                                +

                                You can also use the spacebar to jump.

                                + +
                                + +
                                +
                                + +
                                +

                                Congrats!

                                +

                                You reached the last checkpoint.

                                +
                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                +

                                freeCodeCamp Code Warrior

                                +

                                + Help the main player navigate to the yellow checkpoints. +

                                +

                                + Use the keyboard arrows to move the player around. +

                                +

                                You can also use the spacebar to jump.

                                + +
                                + +
                                +
                                + +
                                +

                                Congrats!

                                +

                                You reached the last checkpoint.

                                +
                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                +

                                freeCodeCamp Code Warrior

                                +

                                + Help the main player navigate to the yellow checkpoints. +

                                +

                                + Use the keyboard arrows to move the player around. +

                                +

                                You can also use the spacebar to jump.

                                + +
                                + +
                                +
                                + +
                                +

                                Congrats!

                                +

                                You reached the last checkpoint.

                                +
                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                +

                                freeCodeCamp Code Warrior

                                +

                                + Help the main player navigate to the yellow checkpoints. +

                                +

                                + Use the keyboard arrows to move the player around. +

                                +

                                You can also use the spacebar to jump.

                                + +
                                + +
                                +
                                + +
                                +

                                Congrats!

                                +

                                You reached the last checkpoint.

                                +
                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                +

                                freeCodeCamp Code Warrior

                                +

                                + Help the main player navigate to the yellow checkpoints. +

                                +

                                + Use the keyboard arrows to move the player around. +

                                +

                                You can also use the spacebar to jump.

                                + +
                                + +
                                +
                                + +
                                +

                                Congrats!

                                +

                                You reached the last checkpoint.

                                +
                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                +

                                freeCodeCamp Code Warrior

                                +

                                + Help the main player navigate to the yellow checkpoints. +

                                +

                                + Use the keyboard arrows to move the player around. +

                                +

                                You can also use the spacebar to jump.

                                + +
                                + +
                                +
                                + +
                                +

                                Congrats!

                                +

                                You reached the last checkpoint.

                                +
                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 711e173f5d5..033ada62631 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 6fd78b852ca..d99cbf4be8d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 941c82e6291..0701dae2a51 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 50e9360f0c3..226ebec0365 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index f57a75a6b94..c5121378fc5 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index cd6767754da..0ab700240bb 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 006d4bb2153..8440ea67b0a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index b998804835e..3864304d933 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 7ea656a26ea..561369a7979 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index f79fe1ac928..1eef9362cf8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                                /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                                Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index e9cca076298..65d1bacbae7 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                                .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index d7d635454eb..723ad7e4b25 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 6af664aa2fc..0ae5c7ddeca 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 6e048b901d8..b1b0eec3729 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 042959a2328..c7604a1376e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index 6b6368a8439..bb2cb639107 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index cacb944bb9b..f3fd46e438b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index ddabb6b5bc0..0035f568837 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index d3e81848f27..afa53435f15 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index cdde0d313e1..813cfa3e74f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 9800e032534..84564217ef1 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 8c3c0eddb47..6d7c2381ce3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 122e656a170..f3fcca0b583 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index ae9af966d03..68386b95688 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index ae05b4d0679..bef9820c65e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index c137f557118..3c803a0ccbb 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index 66579ac2fde..d2ccda2884b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 00b33629a9c..8b24f90b8fc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index fb42122ce86..ff03f902133 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 35333f91ce8..ad8d5044459 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 310f35d9d27..5a875531544 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index 16a1cfdc52a..3321b942c90 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index d265e0d6ebf..7dbace3c728 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index e0253fada55..546337eac9c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 56bb3c95d26..cab6274e68a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 5529daa0a18..3754cbb4a48 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 932050da45b..34733a0dfa8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index af4f58c980e..b11404c0fa5 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index fa60efba4bb..79d594bd9f4 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 606a2f3c5c9..bda0b7aae77 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                                .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index 821009a6f84..d9b16b2de28 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index 46b4f675589..98806920eb6 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 513b3c3ed99..db9c7fd1d75 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 080e5e186a1..5d2329cf195 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 6afeaf034bf..f9a14ebaa66 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 815176b6cff..7c365655243 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 7d7fc38601f..2a3f631a6c3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index 7935b15618b..8d061ce500d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index 2c9c3580ffe..7f177219a30 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 7bb2e78b95d..dd15642edb8 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 084998093ee..f60779b5f00 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 14318219ed9..8df088020f3 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 14e92a97ce5..4d7202f2f9e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index 0945566c6ff..82dfb62ce09 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index a9eff70371f..b1b9f9820fc 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index 61ce36744d5..8d5c030ea9e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 3ad8c8967ce..547204b2a47 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index e6bd7b16ae0..0157518d1f4 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index efcdb994262..d35df261005 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 5ce9eed4b0b..d0830fa8340 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index cd6e6ecc0fc..b941bc0f62e 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 69f0207dc99..7176223a75f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 29858af9f74..4664165a66a 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 0ed8b8a6c73..0020661951d 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 1bf2ab966b6..451ac7f5e66 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 6583db18f0c..b9de51b0d52 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 6df135622e9..eb3e0f1b98b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 3ca82fb6893..9829de648ab 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 9310cd9c68f..6d1a343fb6f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 955ecf22396..17b6fb04e8c 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index dc12f04cc7c..2a2391056df 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index c58dd15c858..acf5c4b212b 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index da96053247d..a68528b104f 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index b7d6e279148..95817266274 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index 2df6307a947..d01f5650f13 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 2978be4e3f9..ca418cac637 100644 --- a/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/japanese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/japanese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 165e0d47d48..bbf99ded4e2 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                                Creamy Chocolate Fudge

                                - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                                Description

                                This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                                This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                                diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 19fbaa411fa..39b4f0ae3bd 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 9ea6a1913b4..f475b5ede38 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/japanese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 32861ac8835..185b29f5c52 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ Closing tags tell the browser where an element ends. They are almost the same as A full paragraph element looks like this: -element diagram +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/japanese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/japanese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/japanese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/japanese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                              • + + +
                              • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                +
                                +
                                +
                                +
                                +
                                +
                                +

                                freeCodeCamp

                                +
                                +
                                +
                                +
                                +
                                +
                                +
                                + song cover art +
                                +
                                +
                                +

                                +

                                +
                                +
                                + + + + + +
                                +
                                +
                                +
                                +
                                +
                                +
                                +
                                +
                                +
                                +

                                Playlist

                                +
                                +
                                +
                                +
                                +
                                +
                                  +
                                  +
                                  + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                • + + +
                                • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +

                                  freeCodeCamp

                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  + song cover art +
                                  +
                                  +
                                  +

                                  +

                                  +
                                  +
                                  + + + + + +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                  +

                                  Playlist

                                  +
                                  +
                                  +
                                  +
                                  +
                                  +
                                    +
                                    +
                                    + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                  • + + +
                                  • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 74f789f7f64..9a90c8c9771 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index a8ee33e9288..4782f9bda55 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index 547d0c9bd6a..34560899e75 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index 1d78f28f2e2..9d3cc398d38 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index f94c50a366d..cf4f3b3fd9c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 73b77a857df..71690b72723 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 3edbd1019cd..eb2683f23f8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index cbd67637923..f0d3e68b0a1 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 17ea1556aa5..445ceb01f55 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index e42497c75ad..6189ecbc6be 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 58c6fb34389..88167fa9ad4 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 3cafad4cdbc..11581586d1a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index bfcc82f33c1..3df81508d1c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index ef544ee4a02..a80400b7544 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 6aaa29790bc..43114466119 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index e699ab36a6d..a1cb17ffdcc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index 160cf24ddc5..6494e0f4fe3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index 28269086a77..f3d5810a45a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index 3a1fe506059..5a7f7d149a2 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index e8125a7f3a8..e2444921ffb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 45d09238166..b229db26523 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index bf7d81a7a35..452a67e0a7a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index ee5b7a363f8..1a8ac5c0dd1 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 4567acb5c4f..0bd5378aacb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 41ca4cc37d8..a2b1c32963b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index fdb2fbc7f66..5bf78fddba8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index d076c93f8b1..6aebc1198c9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index c6202937f44..52e7196d9c4 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 030392d6643..a7b45ed8ae5 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index 2118d0b1b8c..e39b62119b3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index 0e8628f0753..025e3ed252c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index ce744214775..2e4cdf50997 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index b30649cac4c..3a56237320a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index d1ff45d93b8..0b1b9231c5c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 5ab9533c25b..24dbd8382ff 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index ac7d5cb587d..a24612d164f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 9e78fb699e2..c056ee9cc52 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index d05dfbf082d..d4cd7d8d815 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index 7de9930adb4..32f5322e3de 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 85511623913..54c8be2a29e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index a419709eb89..03848ea99b5 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 851f7145f98..92e37d9a6f6 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index 70ca8e9a749..8f13454d8eb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 45a31ac9cf7..4e353375ecd 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index ba4c7c89ace..8a252248466 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 86131e4799c..5940b7c1073 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index b77d3b97c06..f35ac4d4681 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Step 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 03ddec5b50a..f290586fdd9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Step 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index f9092d051ba..12cfc0ac73b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Step 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 177c1e9530f..12fe1c37d51 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Step 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index e4a66ca75b6..b951a3e6536 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Step 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 9568bde8f28..4c8d4e75a7d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Step 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index a517be5aca0..9623313563f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Step 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 8c0000f51cd..1e3ad2606b7 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Step 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 59edd2974a4..6d5f984a543 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Step 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index 9e5fbc487db..09a6c46c14b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Step 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index bcdee639238..33379e677b3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Step 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 1e4a4143139..83a323889a9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Step 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 9cd967ab567..cac4131d84c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Step 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 9835c452935..5544f4b3398 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Step 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 41c4e61853e..5e3a93aee81 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Step 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index c2acdf72935..1e5ffcb96ab 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Step 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index e508d6e5706..d2bd27ec59e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Step 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 1b8f6b651b4..ff528b02d09 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Step 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 9da49c411c0..1b61fb95bb0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Step 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 9eda3acb931..a09f0d04543 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Step 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 59f5e533ca4..a9c705c8ffc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Step 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index b8f0e4e2c1d..ea938883a6d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Step 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index b4f3fa00d1a..7ad19036d5c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Step 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index fcf3c262772..b259524d2d5 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Step 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 741c055f1b1..fc3853e0f9f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Step 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index b06d1bf7612..48876b1a321 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Step 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index 6a71eaecb91..9542bb0ae4b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Step 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 48be246c1e4..8d90b2e7567 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Step 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index c01f0cea830..584c0120446 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Step 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 6f540ffba9f..912088799f4 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Step 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index a4cec17821d..d6b340e5910 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Step 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 0008d72b607..2927aa25e15 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Step 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 4bd72562aa6..8c47159e369 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Step 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 599eb400ff8..dfa712b747e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Step 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index 1fde2b22720..50bb9396457 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Step 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 1ffe76212d0..1934be67533 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Step 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 40e0ff550b2..be95a9ed587 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Step 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index fbf45229c8b..ad46a890b6a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Step 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index efb4f904360..0bc62245d07 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Step 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 5a93da5f973..fd5e074f80b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Step 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index c638afa6b92..39e1709c26b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Step 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index c16c37a9119..5f6bbcc31bc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Step 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 8b70856c84a..18d20539301 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Step 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 4fc8800501d..ef1e2ee14af 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Step 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 70130de1347..ce28b2e7ee8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Step 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index e27db5c4318..7553b5a3bcf 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Step 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index 6d61f54e3b6..f69ae8d55ea 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Step 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index d7598fde8d9..574dd40d018 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Step 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index eaeeaf00e22..860719bde4d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Step 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 4fc4b477f75..a8d5e05af40 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Step 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index fe4ef487def..a92a271963d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Step 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 6a2319095b7..715d320b1fc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Step 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index e8f32580595..2bbb5741491 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Step 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index cbef4344406..71ddeb1f7d1 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Step 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index e2a40e7de0b..d36c032c925 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Step 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index b58b51ae302..b2225896955 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Step 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index fb78953bc72..89fc9c774f7 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Step 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index f7360bfc4d9..f56783e00f9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Step 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index 930f5809767..4c086b317ea 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Step 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 42fe47de826..f4fd39bde3b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Step 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 871e35007f6..d263bdf54b3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Step 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index eeb8bc378e4..303311211d4 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Step 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 952978d5c8a..e0e1e7204cc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Step 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 2bc5e567f4f..545d5ddcd3d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Step 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 211e045117d..01c426e728d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Step 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index be8a3ebba64..8b3cb1b4f83 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Step 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index a9de3dcdbd5..d9b122d8549 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Step 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 79eda0fba07..0aa52253c4b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Step 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 4183273e53c..2a72a101773 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Step 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 68b0b517272..f19e076fca6 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Step 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 63ce891a2c3..dc6d63565b3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Step 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index fee261dc90c..a68f265ff2d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Step 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 5ea8e18be2b..bf5ba8ab818 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Step 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 7a67576ffa7..a6b0501236d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Step 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index c8479511f3a..7efda9045cc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Step 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 827bfdf41cc..a4531f7b311 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Step 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 4b2d81c3c67..5874bb8eb4d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Step 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index 3ea22dd84e5..28877ef405a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Step 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index afbdc50e5a5..d7376bb2d78 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Step 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 18f8ff7d6d9..7fbf61939fb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Step 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 7b3ddef9804..9c4c2d9490f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Step 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index ef192444f29..2d4ad2dc17c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Step 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 6ee87a986ef..882f5359853 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Step 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index fe3890964ea..21101bab723 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Step 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 9d5f6830f28..00176126504 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Step 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 1a09fb4ed71..26fa7e4c5ab 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Step 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index ecedd30bbea..1110cb36177 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Step 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 35533919bb2..0f20baeab9a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Step 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index 12050701935..d13a7eb5ed3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Step 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 170fa8120b1..6daf63db3d9 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Step 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index df364f0ea8d..9670a73667e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Step 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 8a7964ea682..c2f4268dba0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Step 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index bd6fca9a403..e647743e443 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Step 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index 373b02e6486..71006ed6e31 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Step 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index c046f2d48c7..7739d08bdfc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Step 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 30b27d5b79c..be957205c33 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Step 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index a5cedbd41d2..d2904f5090e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Step 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index a8833ffbb1c..b5af6d28b69 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Step 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index f7bbbb1edad..fd993364550 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Step 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index f21e554535e..051e7974e36 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Step 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 93460e80702..95438a380ba 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Step 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 7758905840a..f60366890bc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Step 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                    +

                                    freeCodeCamp Code Warrior

                                    +

                                    + Help the main player navigate to the yellow checkpoints. +

                                    +

                                    + Use the keyboard arrows to move the player around. +

                                    +

                                    You can also use the spacebar to jump.

                                    + +
                                    + +
                                    +
                                    + +
                                    +

                                    Congrats!

                                    +

                                    You reached the last checkpoint.

                                    +
                                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                    +

                                    freeCodeCamp Code Warrior

                                    +

                                    + Help the main player navigate to the yellow checkpoints. +

                                    +

                                    + Use the keyboard arrows to move the player around. +

                                    +

                                    You can also use the spacebar to jump.

                                    + +
                                    + +
                                    +
                                    + +
                                    +

                                    Congrats!

                                    +

                                    You reached the last checkpoint.

                                    +
                                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                    +

                                    freeCodeCamp Code Warrior

                                    +

                                    + Help the main player navigate to the yellow checkpoints. +

                                    +

                                    + Use the keyboard arrows to move the player around. +

                                    +

                                    You can also use the spacebar to jump.

                                    + +
                                    + +
                                    +
                                    + +
                                    +

                                    Congrats!

                                    +

                                    You reached the last checkpoint.

                                    +
                                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                    +

                                    freeCodeCamp Code Warrior

                                    +

                                    + Help the main player navigate to the yellow checkpoints. +

                                    +

                                    + Use the keyboard arrows to move the player around. +

                                    +

                                    You can also use the spacebar to jump.

                                    + +
                                    + +
                                    +
                                    + +
                                    +

                                    Congrats!

                                    +

                                    You reached the last checkpoint.

                                    +
                                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                    +

                                    freeCodeCamp Code Warrior

                                    +

                                    + Help the main player navigate to the yellow checkpoints. +

                                    +

                                    + Use the keyboard arrows to move the player around. +

                                    +

                                    You can also use the spacebar to jump.

                                    + +
                                    + +
                                    +
                                    + +
                                    +

                                    Congrats!

                                    +

                                    You reached the last checkpoint.

                                    +
                                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                    +

                                    freeCodeCamp Code Warrior

                                    +

                                    + Help the main player navigate to the yellow checkpoints. +

                                    +

                                    + Use the keyboard arrows to move the player around. +

                                    +

                                    You can also use the spacebar to jump.

                                    + +
                                    + +
                                    +
                                    + +
                                    +

                                    Congrats!

                                    +

                                    You reached the last checkpoint.

                                    +
                                    + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 711e173f5d5..033ada62631 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 6fd78b852ca..d99cbf4be8d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 941c82e6291..0701dae2a51 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 50e9360f0c3..226ebec0365 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index f57a75a6b94..c5121378fc5 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index cd6767754da..0ab700240bb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index a26fb7d161b..2c87332d49e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index b998804835e..3864304d933 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 7ea656a26ea..561369a7979 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index f79fe1ac928..1eef9362cf8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                                    /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                                    Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index e9cca076298..65d1bacbae7 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                                    .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                    Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index d7d635454eb..723ad7e4b25 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 6af664aa2fc..0ae5c7ddeca 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 6e048b901d8..b1b0eec3729 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 042959a2328..c7604a1376e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index 6b6368a8439..bb2cb639107 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index cacb944bb9b..f3fd46e438b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index ddabb6b5bc0..0035f568837 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index d3e81848f27..afa53435f15 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                    Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                    Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                    Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                    Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                    Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                    Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index cdde0d313e1..813cfa3e74f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 9800e032534..84564217ef1 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 8c3c0eddb47..6d7c2381ce3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index b71b80b4945..0b26aaa78d8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index ae9af966d03..68386b95688 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index ae05b4d0679..bef9820c65e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index c137f557118..3c803a0ccbb 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index 66579ac2fde..d2ccda2884b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 00b33629a9c..8b24f90b8fc 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 2b2127f2900..8b3076faef0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 1b0f70d54fa..e2a3bdea38b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 2b3e27954b5..4d3b925dc0e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index d07fecf9884..a23ecec0452 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index 61c813df7b0..1a88c18b540 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 0f286ea628e..363b500d39e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 69d62d8ac8b..e0ae284ba72 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 63afcc88ad3..dcdf7498af0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index a0d563ea007..55f137ec96e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index d43ca422ab1..ba796775a2e 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index 66376b9472b..d258e16d619 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 606a2f3c5c9..bda0b7aae77 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                                    .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                    Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index a0ad7091f21..fc2ceb64414 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index 46b4f675589..98806920eb6 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 513b3c3ed99..db9c7fd1d75 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 080e5e186a1..5d2329cf195 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 6afeaf034bf..f9a14ebaa66 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 815176b6cff..7c365655243 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 7d7fc38601f..2a3f631a6c3 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index 7935b15618b..8d061ce500d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index 2c9c3580ffe..7f177219a30 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 7bb2e78b95d..dd15642edb8 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 79e3ea7f555..13b6404bf58 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 417198b49f7..2127d495c69 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index fedae3d12d0..3b0dc49177c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index f024c0e76be..cbc34986ef5 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 4c8835a63af..55260992c8c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index dca25c5f235..7bf835e2980 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 36c24d4ca35..ffd281ac734 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index 21184d40203..aa1b27b3b8b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index 66df6f684c3..26a74a97b57 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 8fb8316a1e1..3203771112a 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 140c6dcc7a1..752158c5e06 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index ac9ed2c01f1..d4228908e6c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 2b399edcf8a..f315cc7d46b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 710440a0588..2c0000dfc53 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 3f7887371ff..e4ed7887401 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index cd6abfb5ff8..1e57d6fbc9c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 1c8d1ea3c62..861ea76c78b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 3ca82fb6893..9829de648ab 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 9310cd9c68f..6d1a343fb6f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 955ecf22396..17b6fb04e8c 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index dc12f04cc7c..2a2391056df 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index c58dd15c858..acf5c4b212b 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index da96053247d..a68528b104f 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index b7d6e279148..95817266274 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index 2df6307a947..d01f5650f13 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 2978be4e3f9..ca418cac637 100644 --- a/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/korean/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/korean/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/korean/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 165e0d47d48..bbf99ded4e2 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                                    Creamy Chocolate Fudge

                                    - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                                    Description

                                    This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                                    This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                                    diff --git a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 6ab4cb1f90e..02bdcd20a2b 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 9ea6a1913b4..f475b5ede38 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/korean/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/korean/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 32861ac8835..185b29f5c52 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ Closing tags tell the browser where an element ends. They are almost the same as A full paragraph element looks like this: -element diagram +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/korean/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/korean/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/korean/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/korean/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                  • + + +
                                  • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +

                                    freeCodeCamp

                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    + song cover art +
                                    +
                                    +
                                    +

                                    +

                                    +
                                    +
                                    + + + + + +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                    +

                                    Playlist

                                    +
                                    +
                                    +
                                    +
                                    +
                                    +
                                      +
                                      +
                                      + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                    • + + +
                                    • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +

                                      freeCodeCamp

                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      + song cover art +
                                      +
                                      +
                                      +

                                      +

                                      +
                                      +
                                      + + + + + +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                      +

                                      Playlist

                                      +
                                      +
                                      +
                                      +
                                      +
                                      +
                                        +
                                        +
                                        + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                      • + + +
                                      • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index bc31f5f04ac..247eeeafdbd 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Você não deve ter um ponto-e-vírgula após a chamada de `fetch`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index 363b49a8956..92a6b11a943 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Você não deve ter um ponto-e-vírgula depois da chamada de `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index f70327dc8bb..3be6b6680f2 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ Você não deve ter um ponto-e-vírgula depois da chamada de `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index c295651e0c5..8b4a03101a3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu O primeiro `.then()` não deve ter um ponto e vírgula. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` Você deve encadear outro `.then()` ao método `.then()` existente. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 348be049867..9a00383b110 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu O segundo método `.then()` deveria registrar `data` no console usando console.log(). ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` O segundo `.then()` não deve ter um ponto-e-vírgula. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` Você deve encadear o método `.catch()` no segundo `.then()` que você já tem. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` Você deve adicionar um parâmetro `err` ao método `.catch()`. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` O método `.catch()` deve usar a sintaxe das arrow functions. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Não se esqueça de usar as crases no início e no fim da string. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 96f59a1829c..f891bd5873e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) Você deve definir a variável `startingIndex` como `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` Você deve usar `let` para declarar uma variável chamada `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) Você deve definir a variável `endingIndex` como `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` Você deve usar `let` para declarar uma variável chamada `authorDataArr`. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index f305babd9a6..693b42842f4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) A função `displayAuthors` deve estar vazia. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index b2eca0e83e2..9ecd5e8cbff 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) A função de callback deve estar vazia. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index fd97e5a7b32..d028cea3992 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) Você deve usar a atribuição composta para adicionar uma string de template literals vazia ao `innerHTML` de `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index c9d879aa58c..d415cabe81a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ Primeiro, remova a instrução do `console.log()`. Em seguida, atribua `data` à Você deve remover o registro do console que mostra `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` Você deve atribuir `data` à variável `authorDataArr`. ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index c90ce2fc66d..23969f68e8e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the Você deve atribuir `data` à variável `authorDataArr`. ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` Você deve ter um registro do console com o texto `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index f1ed4a487fe..ab258287ea9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ Primeiro, remova a instrução do console.log() mostrando `authorDataArr`. Em se Você deve atribuir `data` à variável `authorDataArr`. ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` Você deve remover a instrução do console.log() mostrando `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` Você deve chamar a função `displayAuthors`. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) O primeiro parâmetro do método `slice()` deve ser `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index a3cb293e818..f93aaf7cb8a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Dentro da função `fetchMoreAuthors`, defina ambas as variáveis `startingIndex Você deve definir a variável `startingIndex` como `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` Você deve definir a variável `endingIndex` como `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index 5a1bea43022..48817fe5312 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) O "ouvinte" do evento deve receber `fetchMoreAuthors` como a função para ser executada. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 31bced4f19d..82286174744 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ Se essa condição for atendida, desabilite o botão definindo a propriedade `di Você deve definir a propriedade `disabled` de `loadMoreBtn` como `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` Você deve definir o `textContent` do botão `loadMoreBtn` como `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index ffd4d1236bb..9fad0c6d53c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Dentro do `.catch()`, remova `console.error()` e defina o `innerHTML` de `author Você deve remover a instrução `console.error` e seu texto. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` Você deve acessar o `innerHTML` de `authorContainer` e defini-lo como um elemento `p`. Não se esqueça de cercar o elemento `p` com uma template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) O elemento `p` deve ter o texto `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index 87c01c538c9..3bef45967bc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) Você deve definir o valor da propriedade `cursor` para `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63b60d3c5048302906962231.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63b60d3c5048302906962231.md index 5efa98b8ff3..7eba29c6678 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63b60d3c5048302906962231.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63b60d3c5048302906962231.md @@ -29,13 +29,13 @@ Você deve criar uma variável chamada `calorieCounter`. assert.isDefined(calorieCounter); ``` -You should have `document.getElementById('calorie-counter')` in your code. +Você deve ter `document.getElementById('calorie-counter')` no código. ```js assert.match(code, /document\.getElementById\(\s*('|")calorie-counter\1\s*\)/g); ``` -You should assign `document.getElementById('calorie-counter')` to your `calorieCounter` variable. +Você deve atribuir uma variável `document.getElementById('calorie-counter')` a `calorieCounter`. ```js assert.equal(calorieCounter, document.getElementById('calorie-counter')); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index 0df71214754..afa88cfbc78 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Ainda dentro do bloco do `if`, defina `isError` como `true` e retorne `null`. Após o `alert`, você deve definir `isError` para `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` Após modificar `isError`, você deve usar `return` para retornar o valor `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index c02dfe43b54..453704aa674 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); A instrução `if` deve usar `return` para terminar a execução da função. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index eaeab00e615..837f3894879 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ Você deve atribuit um template literal vazio à propriedade `innerHTML` do elem ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 3d33ef9b1cc..6078504e706 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare uma função aninhada `createLabel` usando a sintaxe das arrow functions Você deve declarar uma variável `createLabel` na função de `onload`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` A variável `createLabel` deve ser declarada após a variável `container`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` A variável `createLabel` deve ser declarada com `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` A variável `createLabel` deve ser uma arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` A função `createLabel` deve receber um parâmetro `name`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` A função `createLabel` deve estar vazia. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index a342059f016..90506eddb9d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); Você deve adicionar `label` após definir os atributos. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index 73c1ade7074..13444794344 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); Você deve passar uma função de callback para `.forEach()` usando a sintaxe das arrow functions. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função de callback deve ter `number` como o único parâmetro. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 9072741fe9b..516cbb19b25 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Em seguida, chame o método `.forEach()` no array `letters`. Passe uma função Você deve chamar a função `createLabel()`. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` Você deve passar `number` para a chamada de `createLabel()`. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` Você deve chamar o método `.forEach()` no array `letters`. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) Você deve passar uma função de callback que use a sintaxe das arrow functions para o método `.forEach()`. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` A função de callback deve receber um parâmetro `letter`. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` A função de callback deve estar vazia. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ A função de callback `letters.forEach()` deve ser aninhada dentro da função de callback `range(1, 99).forEach(number => {}`. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index c0f02926c30..20d19933c93 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); A função `sum` deve usar a sintaxe das arrow functions. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função `sum` deve receber um parâmetro `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` A função `sum` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` A função `sum` deve retornar o resultado da chamada de `.reduce()` em `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` A função `sum` deve retornar a soma de todos os números em `nums`. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 2bfe0c57488..68ff2be3778 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); A função `isEven` deve usar a sintaxe das arrow functions. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` A função `isEven` deve usar o operador de módulo `%`. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 54c7f12593b..481d5c247bb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); A função `average` deve usar a sintaxe das arrow functions. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função `average` deve ter um parâmetro `nums`. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` A função `average` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` A função `average` deve retornar o valor da média do array `nums`. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index a93d57ca51d..5d2045f0f25 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); A função `median` deve ter um parâmetro `nums`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` A função `median` não deve usar um retorno implícito. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` A função `median` deve ter uma variável `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` Você deve usar `const` para declarar a variável `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` Você deve usar `.slice()` para atribuir uma cópia do array `nums` para `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` Você deve encadear o método `.sort()` ao método `.slice()`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` Você deve passar uma função de callback para o método `sort` para ordenar corretamente os números em ordem ascendente. Use um retorno implícito para deixar claro. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index 291ed1af9de..80a4f6b5249 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n Você deve atribuir o comprimento do array `sorted` à variável `length`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` Você deve declarar uma variável `middle` após a variável `length`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` Você deve usar `const` para declarar a variável `middle`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` Você deve atribuir a `middle` o valor da divisão da variável `length` por `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` Você deve subtrair `1` do cálculo de `length / 2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8057c85f371..9431adbe674 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Usando a sintaxe do operador ternário, verifique se `length` é par usando a fu Você deve usar a palavra-chave `return`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` Você deve chamar a função `isEven()` após a palavra-chave `return`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` Você deve passar a variável `length` para a chamada de `isEven()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` Você deve usar sintaxe dos operadores ternários para verificar a veracidade da chamada de `isEven()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` Se o ternário for verdadeiro, você deve chamar a função `average()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` Você deve passar um array para a função `average()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` O primeiro elemento do array passado para `average()` deve ser o elemento no índice `middle` do array `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` O primeiro elemento do array passado para `average()` deve ser o elemento no índice `middle + 1` do array `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` Se o ternário for falso, você deve retornar o valor de `sorted` no índice `middle`. Use `Math.ceil()` para arredondar o valor de `middle` para cima. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index a24ff13507b..1f8d5f2b08c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); A função `update` deve receber um parâmetro `event`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` A função `update` deve estar vazia. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index bbcdec90677..b6671ee339f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ A propriedade `target` do evento change representa o elemento que mudou. Atribua Você deve declarar uma variável `element` na função `update`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` Você deve usar `const` para declarar a variável `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 06f8b00fcb8..dc425a9d46e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Atribua a propriedade `value` de `element` a uma nova variável chamada `value` Você deve declarar uma variável `value` após a variável `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` Você deve usar `const` para declarar a variável `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` Você deve atribuir a propriedade `value` de `element` à variável `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` Você deve chamar o método `.replace()` da propriedade `value` de `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` Você deve passar uma expressão regular que corresponda a um espaço em branco no método `.replace()`. Use a classe de caractere `\s`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` Você deve tornar a expressão regular global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` Você deve passar uma string vazia como segundo argumento para o método `.replace()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index 98982c3866c..dbf1b9bd013 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Agora, você precisa verificar se `value` não inclui o `id` do elemento. Crie u Você deve criar um bloco `if`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` A condição `if` deve verificar se `value` inclui o `id` de `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` O bloco `if` deve estar vazio. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 0c45afd8437..5c3eca64dcf 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. Você pode usar `[0]`, `.startsWith()` ou `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 1de1516ac64..8fd9e5bcdd7 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s A variável `idToText` deve ser uma arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função `idToText` deve ter um parâmetro `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` Você deve atribuir a `idToText` o resultado da chamada do método `.find()` no array `cells`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` Você deve passar uma função de callback para o método `.find()`. Use a sintaxe das arrow functions. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função de callback deve ter um parâmetro `cell`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` A função de callback deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` A função de callback deve retornar se `cell.id` é estritamente igual a `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index 1293848a442..502fb0f758a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ A função `idToText`, no momento, retorna um elemento `input`. Atualize-a para Você deve retornar a propriedade `value` do valor de retorno do método `.find()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 68c01b12f6e..43022fbbc98 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Comece declarando uma variável `rangeRegex` e atribua a ela uma expressão regu Você deve declarar uma variável `rangeRegex` após a função `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` Você deve usar `const` para declarar a variável `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` A variável `rangeRegex` deve ser uma expressão regular. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` `rangeRegex` deve usar um grupo de captura. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` `rangeRegex` deve usar uma classe de caractere no grupo de captura. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` `rangeRegex` deve usar uma classe de caractere que corresponda às letras de `A` até `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 207ea36ccb0..94eb47ef207 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Adicione um grupo de captura após o grupo de captura de letras. O novo grupo de Você deve adicionar um segundo grupo de captura a `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` O segundo grupo de captura deve ter uma classe de caractere. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` O segundo grupo de captura deve ter duas classes de caractere. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` A primeira classe de caractere nova deve corresponder aos algarismos de `1` até `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` A segunda classe de caractere nova deve corresponder aos algarismos de `0` até `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` A segunda classe de caractere nova deve ser opcional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index 4270a45435d..3de6e9ac37f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Intervalos são separados por dois-pontos. Após os dois grupos de captura, `ran Você deve adicionar dois-pontos após o segundo grupo de captura. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index fb82a642673..c5f072adb88 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copie seus dois grupos de captura existentes e cole-os após os dois-pontos. Você deve adicionar um terceiro grupo de captura a `rangeRegex`, após os dois-pontos. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` O terceiro grupo de captura deve ter uma classe de caractere. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` O terceiro grupo de captura deve coincidir com os caracteres de `A` até `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` Você deve adicionar um quarto grupo de captura a `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` O quarto grupo de captura deve corresponder a um ou dois algarismos. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index f132943451b..5a5f07efb3f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Por fim, torne a `rangeRegex` global e sem distinção entre maiúsculas e minú `rangeRegex` não deve diferenciar maiúsculas de minúsculas. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` `rangeRegex` deve ser global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` `rangeRegex` deve ser global e não diferenciar maiúsculas de minúsculas. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index d5b7abb4557..ffae5436176 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ Por segurança, faça o parsing de `num1` e `num2` para números inteiros confor Você deve declarar uma variável `rangeFromString` após a função `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` Você deve usar `const` para declarar a variável `rangeFromString`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` A variável `rangeFromString` deve ser uma arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` A função `rangeFromString` deve ter `num1` como primeiro parâmetro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` A função `rangeFromString` deve ter `num2` como segundo parâmetro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` A função `rangeFromString` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` A função `rangeFromString` deve retornar o resultado da chamada da função `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` Você deve chamar `parseInt` com `num1` como argumento e passar o resultado para a chamada de `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` Você deve chamar `parseInt` com `num2` como argumento e passar o resultado para a chamada de `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 135dc8a5a04..93a1025428e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare uma função `elemValue` que receba um parâmetro `num`. A função deve Você deve declarar uma variável `elemValue` após a função `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` Você deve usar `const` para declarar a variável `elemValue`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` A variável `elemValue` deve ser uma arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` A função `elemValue` deve ter `num` como o único parâmetro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` A função `elemValue` deve estar vazia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index 0ae04ba1a9d..c83c7f575df 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Em seguida, retorne a função `inner`. Você deve declarar uma variável `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` Você deve usar `const` para declarar a variável `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` A variável `inner` deve ser uma arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` A função `inner` deve ter `character` como o único parâmetro. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` A função `inner` deve estar vazia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` Você deve retornar explicitamente a função `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index c159bee9f25..e6edc07c564 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ Na função `inner`, retorne o resultado da chamada de `idToText` com `character A função `inner` deve usar um retorno explícito. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` A função `inner` deve retornar o resultado da chamada da função `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` Você deve passar `character + num` como argumento para a função `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 8424bf17da6..78172d5b904 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ Você terá mais prática com isso. Declare uma função chamada `addCharacters` Você deve declarar uma variável `addCharacters`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` Você deve usar `const` para declarar a variável `addCharacters`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` A variável `addCharacters` deve ser uma arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` A função `addCharacters` não deve usar um retorno implícito. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` A função `addCharacters` deve ter um parâmetro `character1`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index b9ef214f688..fb203bbc919 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; A função `addCharacters` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` A arrow function interna deve estar vazia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index c3911193e2c..fd5c98176a4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ As funções internas também podem retornar uma função. Usando a mesma sintax A arrow function interna deve retornar outra arrow function com o parâmetro `num`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` A arrow function mais interna deve estar vazia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index fc7fde7e1eb..cc380a8e16d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Agora, atualize a função mais interna na cadeia de `addCharacters` para que re A função mais interna deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` A função mais interna deve retornar o resultado da chamada de `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` Você deve passar `character1` como o primeiro argumento para a chamada de `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` Você deve passar `character2` como o segundo argumento para a chamada de `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index 7b9b1f02818..55ff5c15ca9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use a mesma sintaxe da função `addCharacters` para atualizar a função `elemV A função `elemValue` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` A função `elemValue` deve retornar implicitamente uma arrow function com um parâmetro `character`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` A arrow function interna deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` A arrow function interna deve retornar o resultado da chamada de `idToText()` com `character + num` como argumento. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index f47174bcc4e..4f94ad89886 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ A função `addCharacters` retorna, no fim, um intervalo de caracteres. Você qu Você deve encadear o método `.map()` à chamada de `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` Você não deve passar nada para o método `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index 618654ef12f..9ebef2143ab 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Passe uma referência à função `elemValue` como a função de callback do mé Você não deve chamar a função `elemValue`. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` Você deve passar uma referência à função `elemValue` como a função de callback de `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index 80660eb23d6..56debb8ae79 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately Você deve chamar `elemValue()` no método `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` Você deve passar `num` para a chamada de `elemValue()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index 1fe5a26b8cb..fbf1c904701 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare uma variável `rangeExpanded` e atribua a ela o resultado da chamada do Você deve declarar uma variável `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` Você deve usar `const` para declarar a variável `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` Você deve atribuir o resultado da chamada de `.replace()` em `x` para a variável `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` Você deve passar `rangeRegex` como o primeiro argumento para `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index c7ab249641b..26ca7e9b748 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ A função de callback receber alguns parâmetros. O primeiro é a string corres Você deve passar uma arrow function como segundo argumento para o método `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` A arrow function deve ter um parâmetro `match`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 56311b5b4f6..7a57c684a53 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Dê à função de callback mais quatro parâmetros para corresponder a esses gr Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index 220d7e0996f..5d1fd54660f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Faça com que a função de callback retorne implicitamente o resultado da chama A função de callback deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` A função de callback deve retornar o resultado da chamada de `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` Você deve passar `num1` como o primeiro argumento para a chamada de `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` Você deve passar `num2` como o segundo argumento para a chamada de `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index b4b53eff5d7..2a2ce43d736 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Chame o método `.map()` na chamada de `rangeFromString()`, passando uma referê Você deve chamar o método `.map()` na chamada de `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` Você deve passar uma referência a `addCharacters` como a função de callback do método `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index abc9a6dce6f..c66ffd356f8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 Você deve chamar a função `addCharacters()` no método `.map()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` Você deve passar `char1` como o primeiro argumento para a chamada de `addCharacters()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index da285281f0f..8b6e959ab49 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, Você deve encadear uma chamada de função à chamada de `addCharacters(char1)`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` Você deve passar `char2` como o primeiro argumento para a chamada de função encadeada. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index b2bcc0ecdd6..d62334319e6 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Coloque no parâmetro `match` um sublinhado como prefixo. Você deve prefixar o parâmetro `match` com um sublinhado. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index 427172ecd1a..95f884cda04 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declarar uma variável `cellRegex` para que corresponda às referências da cél Você deve declarar uma variável `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` Você deve usar `const` para declarar a variável `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` Você deve atribuir uma expressão regular às variáveis `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` A expressão regular deve usar uma classe de caracteres para corresponder aos caracteres de `A` até `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` A expressão regular deve usar uma classe de caractere para corresponder aos dígitos de `1` até `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` A expressão regular deve usar uma classe de caractere para corresponder aos dígitos de `0` a `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` A terceira classe de caractere deve ser opcional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` A expressão regular deve ser global e não deve distinguir maiúsculas de minúsculas. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 30da7529ca3..edc703cdc30 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare uma variável `cellExpanded` e atribua a ela o valor da chamada de `.rep Você deve declarar uma variável `cellExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` Você deve usar `const` para declarar a variável `cellExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` Você deve atribuir a `cellExpanded` o resultado da chamada do método `.replace()` de `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` Você deve passar `cellRegex` como o primeiro argumento para a chamada de `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` Você deve passar uma função de callback usando a sintaxe das arrow functions como segundo argumento para a chamada de `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` A função de callback deve ter um parâmetro `match`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` A função de callback deve estar vazia. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 0c48a3cc185..bfa70471873 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Atualize a função de callback para que retorne o resultado da chamada de `idTo A função de callback deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` A função de callback deve retornar `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` Você deve passar `match` para a chamada de `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` Você deve chamar o método `.toUpperCase()` em `match` ao passá-la para `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index daf669c3126..17d301bfa8d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); A função `highPrecedence` deve usar a sintaxe das arrow functions. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função `highPrecedence` deve ter um parâmetro `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` A função `highPrecedence` deve estar vazia. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index 57a519f5d16..33469a74c47 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Cada número, assim como o operador, deve estar em grupos de captura separados. Você deve declarar uma variável `regex` na função `highPrecedence`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` Você deve usar `const` para declarar a variável `regex`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` A variável `regex` deve ser uma expressão regular. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` `regex` deve usar um grupo de captura. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` O primeiro grupo de captura deve usar uma classe de caractere. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` O primeiro grupo de captura deve corresponder a qualquer algarismo ou a um ponto. Use a classe de caractere especial `\d`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` O primeiro grupo de captura deve coincidir com a classe de caractere uma ou mais vezes. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` `regex` deve usar um segundo grupo de captura. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` O segundo grupo de captura deve corresponder a um operador `*` ou `/`. Use uma classe de caractere no grupo de captura. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` `regex` deve usar um terceiro grupo de captura. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` O terceiro grupo de captura deve ser igual ao primeiro. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index bdf630d03bd..dfd4bef8b4d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare uma variável `str2` e atribua a ela o resultado da chamada de `infixEva Você deve declarar uma variável `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` Você deve usar `const` para declarar a variável `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` Você deve atribuir a `str2` o resultado da chamada da função `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` Você deve passar `str` como o primeiro argumento para a chamada de `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` Você deve passar `regex` como o segundo argumento para a chamada de `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index ac40d8dd4d8..fec5dc98818 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ Se `infixEval` não encontrar nenhuma correspondência, ela retornará o valor ` Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` Você deve usar a palavra-chave `return` com uma condição para verificar se `str` é igual a `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` Você deve usar a sintaxe de operador ternário com a instrução `return`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` Se a condição ternária for verdadeira, você deve retornar `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` Se a condição ternária for falsa, você deve retornar o resultado da chamada de `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` Você deve passar `str2` como argumento para a chamada de `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 7af03e6aa44..b69ee11eaf9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); A função `applyFunction` deve usar a sintaxe das arrow functions. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função `applyFunction` deve ter um parâmetro `str`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` A função `applyFunction` deve estar vazia. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index ee62c4ead65..faa6f52852d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ Primeiro você precisa lidar com os operadores de maior precedência. Declare um Você deve declarar uma variável `noHigh`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` Você deve usar `const` para declarar a variável `noHigh`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` Você deve atribuir `noHigh` o resultado da chamada de `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` Você deve passar `str` como argumento para a chamada de `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index 09b3da9785d..5105f5561d5 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare uma variável `infix` e atribua a ela uma expressão regular que corresp Você deve declarar uma variável `infix`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` Você deve usar `const` para declarar a variável `infix`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` A variável `infix` deve ser uma expressão regular. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` A regex de `infix` deve usar um grupo de captura. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` O primeiro grupo de captura deve usar uma classe de caractere. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` O primeiro grupo de captura deve corresponder a um ou mais algarismos ou a um ponto (para os decimais). Use a classe de caractere `\d`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` A regex de `infix` deve usar um segundo grupo de captura. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` O segundo grupo de captura deve usar uma classe de caractere. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` O segundo grupo de captura deve corresponder a um operador `+` ou `-`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` A regex de `infix` deve usar um terceiro grupo de captura. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` O terceiro grupo de captura deve ser igual ao primeiro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 76ca3bb8ce7..21d98f139ad 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare uma variável `str2` e atribua a ela o resultado da chamada de `infixEva Você deve declarar uma variável `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` Você deve usar `const` para declarar a variável `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` Você deve atribuir a `str2` o resultado da chamada de `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` Você deve passar `noHigh` como o primeiro argumento para `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` Você deve passar `infix` como o segundo argumento para `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index 1cf39031eb5..b214e583819 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declarar uma variável `functionCall` variável e atribua a ela a seguinte expressão regular: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` Essa expressão examinará chamadas de função, como `sum(1, 4)`. @@ -16,19 +16,19 @@ Essa expressão examinará chamadas de função, como `sum(1, 4)`. Você deve declarar uma variável `functionCall`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` Você deve usar `const` para declarar a variável `functionCall`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` Você deve atribuir à função `functionCall` a expressão regular fornecida. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 9c85a303e46..61ae7ad5023 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declara uma função `toNumberList`, que recebe um parâmetro `args` e retorna o resultado da divisão dos `args` por vírgulas e mapeia o array resultante para `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- Você deve declarar uma variável `toNumberList`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` Você deve usar `const` para declarar a variável `toNumberList`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` A variável `toNumberList` deve ser uma arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` A função `toNumberList` deve ter um parâmetro `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` A função `toNumberList` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` A função `toNumberList` deve retornar o resultado da chamada do método `.split()` em `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` Você deve dividir `args` no caractere `,`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` Você deve encadear o método `.map()` ao método `.split()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` Você deve passar uma referência a função `parseFloat` como a função de callback de `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c080216298a..b9bf603262d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare uma função `apply`, que recebe os parâmetros `fn` e `args`. Você deve declarar uma variável `apply`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` Você deve usar `const` para declarar a variável `apply`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` A variável `apply` deve receber uma arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` A função `apply` deve ter `fn` como primeiro parâmetro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` A função `apply` deve ter `args` como segundo parâmetro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` A função `apply` deve estar vazia. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 886581e0325..4d4915c05e4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Lembre-se de que `fn` não pode estar em minúsculas, então você precisará co A função `apply` deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` A função `apply` deve acessar o objeto `spreadsheetFunctions`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` A função `apply` deve acessar a propriedade do objeto `spreadsheetFunctions` que corresponda ao valor de `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` A função `apply` deve chamar o método `.toLowerCase()` em `fn` no acesso à propriedade. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index c4110ed2d83..65dab1f3edb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ A função `apply` está retornando a função de planilha, mas sem aplicá-la. A função `apply` deve acessar a função `spreadsheetFunctions[fn.toLowerCase()]`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` Você deve passar uma chamada de `toNumberList()` para a chamada de `spreadsheetFunctions[fn.toLowerCase()]`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` Você deve passar `args` para a chamada de `toNumberList()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 70da201a6a2..145133d3fe6 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Agora, `applyFunction` precisa retornar um resultado. Retorne o resultado da cha A função `applyFunction` deve retornar o resultado da chamada do método `.replace()` em `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` Você deve passar `functionCall` como o primeiro argumento para a chamada de `.replace()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` Você deve passar uma arrow function vazia como segundo argumento para a chamada de `.replace()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index 8d59700b304..8e478f181fa 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Lembre-se de deixar `fn` em minúsculas. A função de callback deve ter `match` como o primeiro parâmetro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` A função de callback deve ter `fn` como o segundo parâmetro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` A função de callback deve ter `args` como o terceiro parâmetro. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` A função de callback deve usar um retorno implícito. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` A função de callback deve retornar o resultado da chamada do método `.hasOwnProperty()` no objeto `spreadsheetFunctions`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` Você deve passar `fn` para o método .`hasOwnProperty()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` Você deve chamar o método `.toLowerCase()` em `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index d242d4fe8c1..3188cebf88d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use o operador ternário para transformar a chamada de `.hasOwnProperty()` na co A função de callback deve usar a sintaxe dos operadores ternários. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` Se a condição ternária for verdadeira, a função de retorno de chamada deve retornar o resultado da chamada de `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` Você deve passar `fn` como o primeiro argumento para a chamada de `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` Você deve passar `args` como o segundo argumento para a chamada de `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` Se a condição ternária for falsa, você deve retornar `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index c527d3a4db9..748b540b7e1 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Agora, você pode começar a aplicar seu analisador de função para a lógica d Você deve declarar uma variável `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` Você deve usar `const` para declarar a variável `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` Você deve atribuir à variável `functionExpanded` o resultado da chamada da função `applyFunction`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` Você deve passar `cellExpanded` para a chamada de `applyFunction`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 2fed6c2c4de..0e45f56df4c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use um operador ternário para verificar se `functionExpanded` é igual à strin A função `evalFormula` deve usar a palavra-chave `return`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` A instrução `return` deve verificar se `functionExpanded` é igual a `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` A instrução `return` deve usar um operador ternário. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` Se a condição ternária for verdadeira, `evalFormula()` deve retornar `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` Se a condição ternária for falsa, `evalFormula()` deve retornar o resultado da chamada de `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` Você deve passar `functionExpanded` como o primeiro argumento para a chamada de `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` Você deve passar `cells` como o segundo argumento para a chamada de `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index a23024a7cf1..a4c4487c70d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Dentro da instrução `if`, defina `value` em `element` como o resultado da fun Você deve atualizar a propriedade `value` de `element` no bloco `if`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` Você deve atribuir a `value` o resultado da chamada da função `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` Você não deve passar argumentos argumento para a chamada de `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 5920dedba2c..fee20ed3573 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ O primeiro argumento para a chamada de `evalFormula` precisa ser o conteúdo da Você deve passar `value` como o primeiro argumento para a chamada de `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` Você deve chamar o método `.slice()` no argumento `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` Você deve passar o número `1` como argumento para a chamada de `.slice()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index 93db8749993..697620015b1 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ Você pode obter rapidamente todas as células da página pelo `id` do elemento Para o segundo parâmetro da chamada de `evalFormula()`, você deve chamar o método `.getElementById()` do objeto `document`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` Você deve passar `container` como argumento para a chamada de `.getElementById()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` Você deve acessar a propriedade `children` do resultado da chamada de `.getElementById()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index 582f9fd5214..2ddfb747c37 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Infelizmente, a propriedade `children` está retornando uma coleção de element Você deve envolver `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 385e0333783..1a3efbd4577 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); A função `even` deve ter um parâmetro `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` A função `even` deve usar um retorno implícito. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` A função `even` deve retornar o resultado da chamada do método `.filter()` em `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` Você deve passar uma referência à função `isEven()` como a função de callback para o método `.filter()`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` A função `even` deve retornar um array de números pares. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index 306e0f7a786..09a3caf6b5f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 0780acaa87a..3ac8eaea9e5 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 603705b5d8c..9c6c6866e85 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index ccb6ea23282..0b2e17b4897 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index b9f1b89df69..7c7c87d5a6b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index 6457ab9b0d9..056bade6657 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 0826e3328d1..784809defe2 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index 4d6bcadaede..24b75713476 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 6932276f4ee..5d186636e5e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 4d90ead7aea..27b412c16dd 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index 57ed61fcfc0..42cdcdfbe92 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index ff0dd7d78a8..4015185ff2f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index f64c232b588..0b83aea946d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 0657086cd45..83805a1b70d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index 5690bc61a69..8fdfd5e2ecd 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 995cb3ad8cf..46ea964799d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index 15e59ff181c..bad0ca80d22 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 4aeec5e6bb9..a9a8185b73f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index 1b2fe5edaf5..cdd5c82abf9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index fa8f9c038d6..b05da23004c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index 803fd60c6c9..99568e6e9e5 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index ddc1209c14e..d202f0e1dd8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 176fca68583..13f342d8721 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index c2174ff48e4..cf682b36cf7 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 4b558b2232c..cb1ad62b21e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index 92dc1f2458e..a7326f80d99 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index 426f4e43316..2c91dd0fd76 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index fb30181e8f2..6128f1d17fb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Passo 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index f0aace57a1c..8c296eb6c30 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Passo 10 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index cf95e0700f4..12cfc0ac73b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Passo 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index f87724742d7..12fe1c37d51 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Passo 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index 360d39b2eb0..b951a3e6536 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Passo 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 6e0797263f9..4c8d4e75a7d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Passo 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index cda7dbc075d..9623313563f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Passo 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 907fafe551a..1e3ad2606b7 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Passo 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index bc9cb2756d6..6d5f984a543 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Passo 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index eb0d6809267..09a6c46c14b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Passo 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index 7a06dcd738e..33379e677b3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Passo 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 54793f25c6f..83a323889a9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Passo 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index 86c571f1de3..cac4131d84c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Passo 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index ffac0b4c562..5544f4b3398 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Passo 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 1a93d8fb904..5e3a93aee81 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Passo 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index 2b8ae295214..1e5ffcb96ab 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Passo 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index a3cd12bdc3c..d2bd27ec59e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Passo 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 57116d9138c..ff528b02d09 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Passo 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 651a0c9d19b..dcb7da37dd0 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Passo 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 2c3ca547b96..a09f0d04543 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Passo 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 101ebde0553..a9c705c8ffc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Passo 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index 9152900ff7d..ea938883a6d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Passo 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index 1cb68dc707d..7ad19036d5c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Passo 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index 8bc0ded1e84..93b64e98072 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Passo 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index cf160cbc566..fc3853e0f9f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Passo 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index 2e3d7542fe8..7185818c750 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Passo 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index dad8fd60766..9542bb0ae4b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Passo 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 58a43d54786..8d90b2e7567 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Passo 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index 2b9ab3a0c92..584c0120446 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Passo 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 9aa2b449df7..912088799f4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Passo 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index dfc7f5cb92f..d6b340e5910 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Passo 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 01186eadba5..2927aa25e15 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Passo 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 12fe90ca89c..8c47159e369 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Passo 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 0b7ab79dcb8..dfa712b747e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Passo 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index eee3578c99b..50bb9396457 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Passo 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 3a8af31873b..7775d776164 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Passo 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 737b1e80f5b..be95a9ed587 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Passo 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index 026c5d15688..ad46a890b6a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Passo 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index 0732d3ea72e..0bc62245d07 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Passo 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 508647550a1..55300bc8dd4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Passo 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index 4ee6b92aa65..39e1709c26b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Passo 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index a8e3cb953bd..5f6bbcc31bc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Passo 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index 3281df013d6..18d20539301 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Passo 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 9b88eb3b24c..ef1e2ee14af 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Passo 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index 57d8264fc13..ce28b2e7ee8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Passo 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index 087a665b131..7553b5a3bcf 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Passo 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index e43e0a137bb..f69ae8d55ea 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Passo 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index 84979f432d8..574dd40d018 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Passo 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index bdbb34e1885..860719bde4d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Passo 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index 53cd0368c2c..a8d5e05af40 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Passo 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index 62e5142d049..a92a271963d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Passo 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index aa7e95250d9..715d320b1fc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Passo 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index 2bb5e520331..2bbb5741491 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Passo 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index f76c7fff152..71ddeb1f7d1 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Passo 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index 0f3c95549ed..d36c032c925 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Passo 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index 29584e501b4..b2225896955 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Passo 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index ffae4ed092e..89fc9c774f7 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Passo 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index 7829f4b5a5f..f56783e00f9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Passo 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index bed781e840e..4c086b317ea 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Passo 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 7d38deb26e3..f4fd39bde3b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Passo 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index 86fdb5aed28..d263bdf54b3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Passo 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index 978e22a0dab..303311211d4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Passo 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index ae55889a634..e0e1e7204cc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Passo 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index f125f31b634..545d5ddcd3d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Passo 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 2b6076dbf04..01c426e728d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Passo 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index 6adfc4064de..8b3cb1b4f83 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Passo 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index aa81f510644..d9b122d8549 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Passo 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index c7feb78a701..0aa52253c4b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Passo 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index 156d18120b4..2a72a101773 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Passo 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 4d379a7fea6..f19e076fca6 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Passo 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index d6c825c723c..dc6d63565b3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Passo 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index 4e562475022..a68f265ff2d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Passo 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index a76de9389cb..bf5ba8ab818 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Passo 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index bee12cdbd32..a6b0501236d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Passo 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 991247a45de..7efda9045cc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Passo 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 6822d92534b..a4531f7b311 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Passo 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index a117311a0d7..5874bb8eb4d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Passo 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index b72d67de416..28877ef405a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Passo 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index cbe259de6e6..d7376bb2d78 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Passo 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 47367994be1..7fbf61939fb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Passo 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 4cefe9db660..9c4c2d9490f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Passo 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index d09311635c0..2d4ad2dc17c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Passo 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index e1379245fa9..882f5359853 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Passo 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 6c1885aebd6..21101bab723 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Passo 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 820155bdca6..00176126504 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Passo 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index dc6fedd231e..26fa7e4c5ab 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Passo 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index 1f5549ba322..1110cb36177 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Passo 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 24f8dec4481..0f20baeab9a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Passo 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index be0f00beb3a..d13a7eb5ed3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Passo 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 7dde46d16fe..6daf63db3d9 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Passo 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index 7bb6e3c7ac2..9670a73667e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Passo 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index eabc8e5b104..c2f4268dba0 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Passo 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index 3d210533d98..e647743e443 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Passo 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index fd937a56888..71006ed6e31 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Passo 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index 1c817ac8b36..7739d08bdfc 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Passo 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index 42e23f0ba55..be957205c33 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Passo 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 80508d04c91..d2904f5090e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Passo 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index 29e418c5976..b5af6d28b69 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Passo 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index fe743aad962..fd993364550 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Passo 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index 15633e3b212..051e7974e36 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Passo 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 02f29f132f9..95438a380ba 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Passo 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 136cc67c3dd..47a4baf88f5 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Passo 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Parabéns! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                        +

                                        freeCodeCamp Code Warrior

                                        +

                                        + Help the main player navigate to the yellow checkpoints. +

                                        +

                                        + Use the keyboard arrows to move the player around. +

                                        +

                                        You can also use the spacebar to jump.

                                        + +
                                        + +
                                        +
                                        + +
                                        +

                                        Congrats!

                                        +

                                        You reached the last checkpoint.

                                        +
                                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                        +

                                        freeCodeCamp Code Warrior

                                        +

                                        + Help the main player navigate to the yellow checkpoints. +

                                        +

                                        + Use the keyboard arrows to move the player around. +

                                        +

                                        You can also use the spacebar to jump.

                                        + +
                                        + +
                                        +
                                        + +
                                        +

                                        Congrats!

                                        +

                                        You reached the last checkpoint.

                                        +
                                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                        +

                                        freeCodeCamp Code Warrior

                                        +

                                        + Help the main player navigate to the yellow checkpoints. +

                                        +

                                        + Use the keyboard arrows to move the player around. +

                                        +

                                        You can also use the spacebar to jump.

                                        + +
                                        + +
                                        +
                                        + +
                                        +

                                        Congrats!

                                        +

                                        You reached the last checkpoint.

                                        +
                                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                        +

                                        freeCodeCamp Code Warrior

                                        +

                                        + Help the main player navigate to the yellow checkpoints. +

                                        +

                                        + Use the keyboard arrows to move the player around. +

                                        +

                                        You can also use the spacebar to jump.

                                        + +
                                        + +
                                        +
                                        + +
                                        +

                                        Congrats!

                                        +

                                        You reached the last checkpoint.

                                        +
                                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                        +

                                        freeCodeCamp Code Warrior

                                        +

                                        + Help the main player navigate to the yellow checkpoints. +

                                        +

                                        + Use the keyboard arrows to move the player around. +

                                        +

                                        You can also use the spacebar to jump.

                                        + +
                                        + +
                                        +
                                        + +
                                        +

                                        Congrats!

                                        +

                                        You reached the last checkpoint.

                                        +
                                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                        +

                                        freeCodeCamp Code Warrior

                                        +

                                        + Help the main player navigate to the yellow checkpoints. +

                                        +

                                        + Use the keyboard arrows to move the player around. +

                                        +

                                        You can also use the spacebar to jump.

                                        + +
                                        + +
                                        +
                                        + +
                                        +

                                        Congrats!

                                        +

                                        You reached the last checkpoint.

                                        +
                                        + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 2d7118981f4..fb1027f0861 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 236130c3110..4c5737ed199 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index f474ba28abc..b6169724f0f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 8909ccaa2db..5ad196c5858 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Não se esqueça de usar `const` para declarar a variável. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 7d9b3bfe1b0..ed6b2f36f8b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index 3400eb48e39..6123d082b1e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 5c8452a21ab..a5018a063e3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index 2418416f053..d22eb79d10e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index b3fdb550606..e5aa0bdfdb5 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index e85d147ff6b..06a48ab2437 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                                        /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                                        Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index 9685bad7844..873d77346be 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                                        .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                        Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index d0a7671130c..074c8a6b303 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 1d0a931d766..2dc8941188f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 0cb1d81f42c..ac26698b0ba 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index 74c32e6eca5..b5d37d9be1e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index f6cb04ad931..1de549e9073 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index 81ba9bf8772..cf5763c9c02 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index 14f42cff1d2..422a879c621 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index 10e2dbcf7ee..d0e2ff9b2d2 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                        Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                        Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                        Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                        Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                        Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                        Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index a3f771b8df7..b23a44738d2 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index dfc8f02794a..f7e667a3674 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 8fc0641fd88..44d9a1c6ef8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 7d89f91b548..ca9210069d8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index d719bd1e790..7652d848fba 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index 1605b504769..17062551abf 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index ac149c99abb..890b178be18 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index e0d72edc5e2..12eb527971c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 1b78578d877..a699430c8f3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 8ccf5aad0ec..70d78f59d23 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 1dd5a1f0fa8..da6795f9eed 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 07ce0198dc2..0268ece429c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index 16e673d2218..c547c73d1d6 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index 2f09e41aa3f..bc56065e08e 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 04d8bf67798..d2afed54566 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index 0300310d9be..ea414a3ee22 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 311ed31c23f..a7e7ce0a055 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 05b91be6db1..4a292f9b667 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index f8de3f5d9e2..125d939000b 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index 8d1a009e6f4..2e64ddf0f49 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 59f8a899f2b..49d2d623d22 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                                        .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                        Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index 3885659327f..608721a7250 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index 08e18243ac5..a05a3cc1afb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 Neste projeto, você criará um conjunto de cards de time de futebol e aprenderá sobre objetos aninhados, desestruturação de objetos, parâmetros padrão (default), "ouvintes" de eventos e instruções switch. Todo o HTML e o CSS para este projeto foram fornecidos para você. -Comece acessando o `id` chamado `team` do documento HTML e armazenando-o em uma variável `const` chamada `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Lembre-se de que você pode usar o método `getElementById` para isso. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 623da517fa9..dc9e414369d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Em seguida, acesse o `id` chamado `sport` do documento HTML e armazene-o em uma variável `const` chamada `typeOfSport`. Abaixo dessa variável, atribua o `id` de `year` a uma variável `const` chamada `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 649c297a1fb..244db5054b0 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Continuando, acesse o `id` chamado `head-coach` do documento HTML e armazene-o em uma variável `const` chamada `headCoach`. Abaixo dessa variável, atribua o `id` de `player-cards` a uma variável `const` chamada `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index c2325b8ad79..83f5e76a441 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Crie mais uma variável `const` chamada `playersDropdownList` e atribua a ela o `id` `players` usando o método `getElementById`. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 61ca593060f..cd07a6cfc05 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Dentro do objeto `myFavoriteFootballTeam`, adicione uma nova propriedade com uma chave chamada `team` e o valor como sendo uma string que diga `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ O objeto `myFavoriteFootballTeam` deve ter a propriedade `team`. assert.property(myFavoriteFootballTeam, 'team'); ``` -A propriedade `team` deve estar definida como `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index dc31045be31..11edbaccea0 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Abaixo da propriedade `team`, adicione uma nova propriedade com uma chave chamada `sport` e o valor como sendo uma string que diga `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index ceb3635e324..84884f97e19 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Abaixo da propriedade `isWorldCupWinner`, adicione uma nova chave chamada `headCoach` com o valor sendo um objeto vazio. Dentro desse objeto, adicione uma propriedade com a chave `coachName` e um valor como sendo uma string dizendo `Carlos Bilardo`. Abaixo dessa propriedade, adicione outra chave chamada `matches` com o valor sendo o número 7. +Abaixo da propriedade `isWorldCupWinner`, adicione uma nova chave chamada `headCoach` com o valor sendo um objeto vazio. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ O objeto `headCoach` deve ter a propriedade `coachName`. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -A propriedade `coachName` deve estar definida como `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index 6989604506e..208c5844d82 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ O novo objeto deve ter a propriedade `name`. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -A propriedade `name` deve estar definida como `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ O novo objeto deve ter a propriedade `position`. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -A propriedade `position` deve estar definida como `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 3e98d8eb88a..97beee0face 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ O novo objeto deve ter a propriedade `name`. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -A propriedade `name` deve estar definida como `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ O novo objeto deve ter a propriedade `position`. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -A propriedade `position` deve estar definida como `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 640ce15c640..433f513497a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); Você deve atribuir `arr.map()` a `playerCards.innerHTML` usando o operador `+=`. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index f3359f9b833..f565db4eaba 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 No corpo da função de callback, você precisará adicionar template literals, ` `` `, que conterão o conteúdo do HTML para os cards dos jogadores. -Dentro das template literals, adicione uma `div` vazia com a classe `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -Você deve usar as template literals para adicionar uma `div` vazia com a classe `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 5628c55e1c5..1cb25175a82 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 O próximo passo será exibir a palavra `(Captain)` ao lado do jogador se ele estiver listado como capitão do time. -À direita da expressão `${name}`, adicione uma nova expressão incorporada. Dentro dessa expressão, use um operador ternário para verificar se `isCaptain` está definido como verdadeiro (true). Se estiver, retorne `(Captain)`. Caso contrário, retorne uma string vazia. +À direita da expressão `${name}`, adicione uma nova expressão incorporada. Dentro dessa expressão, use um operador ternário para verificar se `isCaptain` está definido como verdadeiro (true). If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -Você deve usar um operador ternário para verificar se `isCaptain` é verdadeiro e retornar `(Captain)` ou uma string vazia. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index 982c2b90ea0..b0ac6b71833 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ Se o operador ternário for verdadeiro, ele deverá exibir o `nickname` do jogad assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -Se o operador ternário for falso, ele deverá exibir a string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 45bd31ee626..23fcc38e447 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 O próximo passo é criar uma função que detectará quando um usuário faz uma seleção em `playersDropdownList`. -Use o método `.addEventListener()` em `playersDropdownList`. Dentro do "ouvinte" do evento, passe o tipo de evento `change` e uma função de callback vazia. +Use o método `.addEventListener()` em `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ Você deve chamar o método `.addEventListener()` em `playersDropdownList`. assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -O "ouvinte" de evento deve "ouvir" o evento de `change`. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index 3b1f060c300..7aa7038e825 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 Se o usuário selecionar `Nicknames` no menu suspenso, você vai querer filtrar os cards dos jogadores que têm um apelido. -Comece adicionando uma cláusula `case` para `nickname` dentro da instrução `switch`. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -Você deve adicionar um novo `case` para `nickname` dentro da instrução `switch`. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index b7dd6e5d18e..3ac8d175bea 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Em seguida, adicione uma cláusula `case` para `forward`. +Next, add a `case` clause for `"forward"`. Dentro desse `case`, chame a função `setPlayerCards` com o argumento `players.filter()`. -Dentro do método `filter()`, adicione uma função de callback com um parâmetro chamado `player` que verificará se `player.position` é igual a `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Por fim, adicione uma instrução `break` abaixo da chamada da função `setPlayerCards`. # --hints-- -Você deve adicionar um novo `case` para `forward` dentro da instrução `switch`. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -No `case` `forward`, você deve chamar a função `setPlayerCards`. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ A função de callback de `filter()` deve receber um parâmetro `player`. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -A função de callback de `filter()` deve retornar implicitamente o resultado da verificação se `player.position` é `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl Você precisará adicionar uma instrução `break` abaixo da chamada de `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index 2c7e01eb8b3..2712be3f87a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Adicione um novo `case` para `midfielder` que verifique se `player.position` é igual a `midfielder` seguindo o mesmo padrão do passo anterior. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -Você deve adicionar um novo `case` para `midfielder` dentro da instrução `switch`. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -No `case` `midfielder`, você deve chamar a função `setPlayerCards`. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ A função de callback de `filter()` deve receber um parâmetro `player`. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -A função de callback de `filter()` deve retornar implicitamente o resultado da verificação se `player.position` é `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s Você precisará adicionar uma instrução `break` abaixo da chamada de `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index 143636b1480..4a6a9c34364 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Adicione um novo `case` para `defender` que verifique se `player.position` é igual a `defender` seguindo o mesmo padrão do passo anterior. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -Você deve adicionar um novo `case` para `defender` dentro da instrução `switch`. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -No `case` `defender`, você deve chamar a função `setPlayerCards`. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ A função de callback de `filter()` deve receber um parâmetro `player`. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -A função de callback de `filter()` deve retornar implicitamente o resultado da verificação se `player.position` é `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p Você precisará adicionar uma instrução `break` abaixo da chamada de `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 75cbf955cba..679194ee050 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Adicione um novo `case` para `goalkeeper` que verifique se `player.position` é igual a `goalkeeper` seguindo o mesmo padrão do passo anterior. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -Você deve adicionar um novo `case` para `goalkeeper` dentro da instrução `switch`. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -No `case` `goalkeeper`, você deve chamar a função `setPlayerCards`. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ A função de callback de `filter()` deve receber um parâmetro `player`. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -A função de callback de `filter()` deve retornar implicitamente o resultado da verificação se `player.position` é `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s Você precisará adicionar uma instrução `break` abaixo da chamada de `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index d15b6b7be99..32fc31482cb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Abaixo da chamada de `setPlayerCards`, adicione uma instrução `break`. Você precisará adicionar uma instrução `break` abaixo da chamada de `setPlayerCards`. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 4cd183beaa1..ed0d4677bd2 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 22f96c302ce..6ee0c658e56 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 9aab99283ac..ee1b02b9e6f 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index b4bf58c07e7..ed496ab56e8 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index e6bac24fd29..0e83559293d 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index 6a8c3b9a46d..1f9f02e3b6c 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 287b8f1ea4b..b866b63cc13 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index 6ef1bc5ecf8..9dd22ee4563 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index 39765831b08..17ef64f5696 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 8e080eb6a3e..99c89b68382 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 879f5f31b71..576702519b2 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 5caf0051430..2e0c8d375f7 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 6eb58aad70f..fc1b5606294 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 1394fb738eb..184449a8762 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index a9a535e7b24..d09128ff717 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 74a69c5f3df..0e4eeb5d730 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 4757cded92a..61e5e81c392 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index 543fe19e005..9e6c46d2a24 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ A instrução `if` deve sair da execução da função. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 9d6e8d82aec..4994f3664fb 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); Você deve usar a sintaxe das arrow functions para atribuir uma função a `isSpam`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função `isSpam` deve receber um argumento único `msg`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` A função `isSpam` deve retornar `false` implicitamente. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 4b1f93a9ff6..d7291a33638 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -No ouvinte do evento, você precisa atualizar o texto do elemento `result`. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. Você deve usar o operador da atribuição para definir a propriedade `textContent` do elemento `result`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` Você deve usar a sintaxe de operador ternário para verificar se `isSpam(messageInput.value)` é verdadeiro. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` A expressão verdadeira do operador ternário deve definir a propriedade `textContent` do elemento `result` como `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` A expressão falsa do operador ternário deve definir a propriedade `textContent` do elemento `result` como `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index a811f4f474e..e656ba3d19a 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` como parâmetro para a função de callback, para ficar claro. A função `isSpam` deve retornar implicitamente o resultado de `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` O método `.some()` deve usar a sintaxe das arrow functions para a função de callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` A função de callback de `.some()` deve receber a expressão `regex` como parâmetro. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` A função de callback de `.some()` deve retornar implicitamente o resultado do teste de `msg` nas `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index 33ac4cb3aca..3be39b1e589 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index c1d9eefbacd..d2e1a0cc9b3 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index e88d2bc96b0..c00364a6d72 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index f2044fc33ad..4b25eac5cfe 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index d65dc05e7e2..87e59d02dd4 100644 --- a/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/portuguese/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/portuguese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 3be458192b1..6ec7c971bdd 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                                        Creamy Chocolate Fudge

                                        - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                                        Description

                                        This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                                        This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                                        diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index b75cca9d8f6..6809e460d3b 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index d962f0d9737..6a0283842ba 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/portuguese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 12de471bbb0..f3ab970f019 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ As tags de fechamento dizem ao navegador onde um elemento termina. Quase sempre, Um elemento de parágrafo completo terá esta aparência: -diagrama de elemento +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/portuguese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/portuguese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/portuguese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/portuguese/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                      • + + +
                                      • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +

                                        freeCodeCamp

                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        + song cover art +
                                        +
                                        +
                                        +

                                        +

                                        +
                                        +
                                        + + + + + +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                        +

                                        Playlist

                                        +
                                        +
                                        +
                                        +
                                        +
                                        +
                                          +
                                          +
                                          + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                        • + + +
                                        • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +

                                          freeCodeCamp

                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          + song cover art +
                                          +
                                          +
                                          +

                                          +

                                          +
                                          +
                                          + + + + + +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                          +

                                          Playlist

                                          +
                                          +
                                          +
                                          +
                                          +
                                          +
                                            +
                                            +
                                            + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                          • + + +
                                          • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index efef4c6e0ec..f1decaae4c9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index ebc6caf7220..7a8c881cea9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index beb628f0792..a390f2a81d0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index c9facd153ba..396ef9dbe45 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 7adc7eadd2e..a029c9566a4 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index f313b1bb0e7..d5de1a3cbd5 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` You should use `let` to declare a variable named `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` You should use `let` to declare a variable named `authorDataArr`. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 819aa1fe95d..2cb6ca7ba81 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Your `displayAuthors` function should be empty. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index 21614f66ff5..eebc912c760 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Your callback function should be empty. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index 3af6953eb53..585581d233e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index f1a89347765..d97b87c66ea 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 3e704ab2f4e..085730d6af6 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 4c8629c9fde..9c9249d982b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index a9dc71b5d34..8f492afdaf9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index aec1184539a..ddb61ba1c50 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index f6469f93c10..0e0bdf080bf 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 9a35f4466a7..c0d6a8357f5 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index 6c530ba9ebf..0aca05166aa 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index ea4aefc9b32..30d1501a60f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index bed8e829741..16c4566e886 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index 056108f423f..f0c1a7527d7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index d05da42236e..9555b49fbb4 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ Declare a nested `createLabel` function using arrow syntax. It should take a `na You should declare a `createLabel` variable in your `onload` function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared after your `container` variable. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Your `createLabel` variable should be declared with `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Your `createLabel` variable should be an arrow function. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `createLabel` function should have a `name` parameter. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Your `createLabel` function should be empty. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index f66f0634f0e..a1c72e63125 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index b98da0fd4be..2a25a6410e8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); You should pass a callback function to `.forEach()` using arrow syntax. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have `number` as the only parameter. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 7243c54a1eb..3d0e46ad79d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` You should pass `number` to your `createLabel()` call. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Your callback function should have a `letter` parameter. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Your callback function should be empty. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index 8d1ddcd5fb5..62022b16c04 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Your `sum` function should use arrow syntax. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `sum` function should have a `nums` parameter. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Your `sum` function should use an implicit return. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `sum` function should return the result of calling `.reduce()` on `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index 9d06932a530..dc616c5b1cb 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Your `isEven` function should use arrow syntax. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 58e532930ff..2f8c0e19def 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Your `average` function should use arrow syntax. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `average` function should have a `nums` parameter. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `average` function should use an implicit return. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index b23e311ab0e..20d3073e5e6 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Your `median` function should have a `nums` parameter. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Your `median` function should not use an implicit return. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Your `median` function should have a `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` You should use `const` to declare your `sorted` variable. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index deb4a393803..8acb7daf2d1 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` You should declare a `middle` variable after your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` You should use `const` to declare your `middle` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index 8c9bacddb49..ae3d276de39 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` You should pass your `length` variable to your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 7b8b7d9ffe6..ad6a08dd318 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Your `update` function should take an `event` parameter. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Your `update` function should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 63c290f2fb7..788395e1d75 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A You should declare an `element` variable in your `update` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` You should use `const` to declare your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index 1dc1617bd6e..b29e9533298 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u You should declare a `value` variable after your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` You should use `const` to declare your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` You should pass an empty string as your second argument to the `.replace()` method. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index e018fb06bbf..e7df783b3d3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 9a418bcf2fb..0c0d310a203 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index 117a075e0f3..b514741ae01 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Your `idToText` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `idToText` function should have an `id` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` You should pass a callback function to your `.find()` method. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your callback function should have a `cell` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index f331b2e13dc..1c58d5f5d88 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index 869aa786b1b..6dbb1881465 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th You should declare a `rangeRegex` variable after your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` You should use `const` to declare your `rangeRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Your `rangeRegex` variable should be a regular expression. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 379d979b83e..35676eb8148 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index db2048f5154..09ce3832d57 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 1d217df30cf..49b5336ee10 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index 97250208fe7..ea1afb15c6c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index f48039d757e..ff06f05db5d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. You should declare a `rangeFromString` variable after your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` You should use `const` to declare your `rangeFromString` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Your `rangeFromString` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Your `rangeFromString` function should have `num1` as the first parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Your `rangeFromString` function should have `num2` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Your `rangeFromString` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your `rangeFromString` function should return the result of calling your `range` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 6e3f9b611c6..a2f8269697b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. The function shoul You should declare an `elemValue` variable after your `rangeFromString()` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` You should use `const` to declare your `elemValue` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Your `elemValue` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `elemValue` function should have `num` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `elemValue` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index d0a3366315c..1aefbb1f1e2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. You should declare an `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` You should use `const` to declare your `inner` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Your `inner` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `inner` function should have `character` as the only parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your `inner` function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index 716a7d4ca9a..36851c69fee 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Your `inner` function should return the result of calling your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 685d62ba96b..521d0b0bb17 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter You should declare an `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` You should use `const` to declare your `addCharacters` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Your `addCharacters` variable should be an arrow function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Your `addCharacters` function should not use an implicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Your `addCharacters` function should have a `character1` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index fdb2fbc7f66..5bf78fddba8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Your `addCharacters` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index e8720b88a53..72984b2d029 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index d5c1b76abff..0f980a9be0f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` You should pass `character1` as the first argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` You should pass `character2` as the second argument to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index bce3cb02167..8729d16153f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Your `elemValue` function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 7f8eb0a90b8..8b6e495b07e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index d076c93f8b1..6aebc1198c9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index fb0d686e40d..ec9f2f6c9c8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` You should pass `num` to your `elemValue()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index c1ef0ae4591..6738d4943a8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep You should declare a `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` You should use `const` to declare your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` You should pass `rangeRegex` as the argument to `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 81a967ea80d..6088a4e3f7d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P You should pass an arrow function as the second argument to your `.replace()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Your arrow function should take a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 4e0bdcafe1b..5400b7ec1ac 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index a976d2e313d..f140dcb4b94 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Your callback should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` You should pass `num1` as the first argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` You should pass `num2` as the second argument to your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 7a1435a9e93..1bb2255fed2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index c6980b6b44a..61a805a384d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` You should pass `char1` as the argument to your `addCharacters()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index 0af42bfb322..ac307c3a146 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index daa12199dcb..3768c50634c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index e9f8b5ce15d..b8474341679 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette You should declare a `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` You should use `const` to declare your `cellRegex` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 3fa9bd07097..7a43a446493 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() You should declare a `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` You should use `const` to declare your `cellExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` You should pass `cellRegex` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Your callback function should have a `match` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Your callback function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index 4e1043eecb1..e344f41147a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index f9fcf26f42e..4ef6f1597aa 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Your `highPrecedence` function should use arrow syntax. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `highPrecedence` function should have a `str` parameter. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `highPrecedence` function should be empty. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index d7bdc37d7b2..6ea58bc46e0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. You should declare a `regex` variable in your `highPrecedence` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` You should use `const` to declare your `regex` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Your `regex` variable should be a regular expression. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index 167d450138d..6311798060f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` You should declare a `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `str` as the first argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` You should pass `regex` as the second argument to your `infixEval` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index 660a596da8e..3a66e0d1799 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` You should pass `str2` to your `highPrecedence()` call. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 0bc08a4012e..9e4657a50f7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Your `applyFunction` function should use arrow syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `applyFunction` function should have a `str` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Your `applyFunction` should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 16562b4bb2f..14138e9ca93 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var You should declare a `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` You should use `const` to declare your `noHigh` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` You should pass `str` as the argument to your `highPrecedence()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index efc5d0ffc18..78368ca5d37 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n You should declare an `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` You should use `const` to declare your `infix` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Your `infix` variable should be a regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 139cf580330..7c817f3c473 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit You should declare a `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` You should use `const` to declare your `str2` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` You should pass `noHigh` as the first argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` You should pass `infix` as the second argument to `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index e84e64dbfe2..e61b9a38b4a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. You should declare a `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` You should use `const` to declare your `functionCall` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 76b05cfc73d..558cef71b0f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- You should declare a `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` You should use `const` to declare your `toNumberList` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Your `toNumberList` variable should be an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Your `toNumberList` function should have an `args` parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Your `toNumberList` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Your `toNumberList` function should return the result of calling the `.split()` method of `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index c9e0af0169c..da034ff8cd9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. You should declare an `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` You should use `const` to declare your `apply` variable. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Your `apply` function should have `fn` as its first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Your `apply` function should have `args` as its second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Your `apply` function should be empty. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index 850121a0317..11e1632f84c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Your `apply` function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your `apply` function should access the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Your `apply` function should access the property of the `spreadsheetFunctions` object that matches the `fn` value. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index f5757ba19eb..773d9dff52b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` You should pass a `toNumberList()` call to your `spreadsheetFunctions[fn.toLowerCase()]` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` You should pass `args` to your `toNumberList()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 83dcd338a09..99952a5bece 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Your `applyFunction` function should return the result of calling the `.replace()` method on `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` You should pass `functionCall` as the first argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index cbfdbf6be78..5eb843c3164 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Your callback function should have `match` as the first parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Your callback function should have `fn` as the second parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Your callback function should have `args` as the third parameter. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Your callback function should use an implicit return. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Your callback function should return the result of calling the `.hasOwnProperty()` method on the `spreadsheetFunctions` object. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` You should pass `fn` to the .`hasOwnProperty()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 1049cf16158..3ec60146d03 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` You should pass `fn` as the first argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` You should pass `args` as the second argument to your `apply()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 222c5c8a20d..0144779f15e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec You should declare a `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` You should use `const` to declare your `functionExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` You should pass `cellExpanded` to your `applyFunction` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 48b1cab80ed..de7fb664c3a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` You should pass `functionExpanded` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` You should pass `cells` as the second argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index c1249111d86..469bf574f9e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index 9ef5920b36a..124a786dab9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c You should pass `value` as the first argument to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` You should pass the number `1` as the argument to your `.slice()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index c2b4d2b8c71..dc4c70b62ac 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` You should pass `container` as the argument to your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` You should access the `children` property of the result of your `.getElementById()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index ac6184b9d56..449e0054421 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index 98ffeb00088..519590a84fa 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Your `even` function should take a `nums` parameter. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Your `even` function should use an implicit return. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Your `even` function should return the result of calling the `.filter()` method on `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index a4c682f9df4..cc8b97da8c6 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 43c6ebe6441..0a62d2e9cc6 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 0e9787dff11..5efd22ab0b7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 983d30989b0..8e04fbe9fc2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index 34ae3e371aa..93ee83dcf49 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index b221e737fdb..c380ecd405a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 89e89d3ac90..5457abbb3fd 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index eb5424ffa9d..41696356307 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 057b43923a9..ad51b78830b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index c46384005c1..f1ae21bf0c7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index 1e8b1fbf12b..9793a9ebf6e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index 56a69dafede..ee91a451b25 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index d523ebec132..c6d12965928 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 521f266e76d..11d2593a35a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index b05d35be8d9..9cffdbe8940 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 36fabde351a..a47cdbb6e5c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index 6c5c07ac62a..5938adeb195 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 298193eba02..6db84b4b5b9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index c29dfeb7ee0..61ae1412fda 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index 7eff7d1311f..af414ed58d5 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index e55198b10be..26ffdf8bbeb 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index 537dc8a9f6a..8075e1eb786 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index b2b659bc314..93f585a8129 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index ffa4ff66d20..9ce326f80f3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 9f557c97e46..5adb3b3b892 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index 327e8b683b6..028dece2260 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index beae452dae8..3eb89c59291 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index bb4cbcd665b..f35ac4d4681 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Hatua ya 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 7a5065c20e7..f290586fdd9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Hatua ya 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index d424809dd57..12cfc0ac73b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Hatua ya 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 805131fe508..12fe1c37d51 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Hatua ya 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index b66dcfec740..b951a3e6536 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Hatua ya 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index e0ae3128f8a..4c8d4e75a7d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Hatua ya 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index 3a4901ded11..9623313563f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Hatua ya 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 82f3e793d0e..1e3ad2606b7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Hatua ya 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index aa6e52f0b03..6d5f984a543 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Hatua ya 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index ccbee19d742..09a6c46c14b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Hatua ya 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index 9be38576749..33379e677b3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Hatua ya 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 40da145f941..83a323889a9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Hatua ya 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index d8e05fbd8d5..cac4131d84c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Hatua ya 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 3dad81b2e4f..5544f4b3398 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Hatua ya 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 62c2bbeb016..5e3a93aee81 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Hatua ya 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index 21ac860070c..1e5ffcb96ab 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Hatua ya 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index d03f544a3b5..d2bd27ec59e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Hatua ya 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 6d338bedcc4..ff528b02d09 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Hatua ya 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index 7ecf5389656..1b61fb95bb0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Hatua ya 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 0a4b0463778..a09f0d04543 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Hatua ya 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index 0907195c69a..a9c705c8ffc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Hatua ya 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index de9d24ba940..ea938883a6d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Hatua ya 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index 32ebc9db7c3..7ad19036d5c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Hatua ya 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index de840dd064a..b259524d2d5 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Hatua ya 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index d2d8f69707b..fc3853e0f9f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Hatua ya 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index 3be7b3825d4..48876b1a321 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Hatua ya 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index d1fc6800c00..9542bb0ae4b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Hatua ya 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 7f94ea6f94e..8d90b2e7567 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Hatua ya 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index b10d3a1060a..584c0120446 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Hatua ya 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index da09c46ac8f..912088799f4 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Hatua ya 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index da88b6bbfc3..d6b340e5910 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Hatua ya 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 18f2e0ee865..2927aa25e15 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Hatua ya 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index ca4b986977d..8c47159e369 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Hatua ya 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index 77779bbd194..dfa712b747e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Hatua ya 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index b661b61479a..50bb9396457 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Hatua ya 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index b6468bf981b..1934be67533 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Hatua ya 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index e81d77ff96f..be95a9ed587 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Hatua ya 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index ed3bd86fbf1..ad46a890b6a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Hatua ya 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index bf9fca08fa3..0bc62245d07 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Hatua ya 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index 61557babf19..fd5e074f80b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Hatua ya 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index bfc6861bbab..39e1709c26b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Hatua ya 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index 2f245861d81..5f6bbcc31bc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Hatua ya 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index c6741ff2a1a..18d20539301 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Hatua ya 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 740e53711f3..ef1e2ee14af 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Hatua ya 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index fcb665995cb..ce28b2e7ee8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Hatua ya 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index 84edfb1a702..7553b5a3bcf 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Hatua ya 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index a0f4291f686..f69ae8d55ea 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Hatua ya 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index 18ed6300859..574dd40d018 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Hatua ya 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index 2ef75b8eb47..860719bde4d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Hatua ya 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index d478c803f7d..a8d5e05af40 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Hatua ya 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index b39e741d55f..a92a271963d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Hatua ya 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 8285ac50206..715d320b1fc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Hatua ya 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index d04cd11d513..2bbb5741491 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Hatua ya 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index 738b1c6c957..71ddeb1f7d1 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Hatua ya 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index b39219426b4..d36c032c925 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Hatua ya 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index 4970b8d2850..b2225896955 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Hatua ya 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index 8a5d2226e14..89fc9c774f7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Hatua ya 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index 934952670ee..f56783e00f9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Hatua ya 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index e65cecd1d97..4c086b317ea 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Hatua ya 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index e24b288c745..f4fd39bde3b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Hatua ya 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index d2bf9611aaa..d263bdf54b3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Hatua ya 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index f124b20563d..303311211d4 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Hatua ya 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 648602884cb..e0e1e7204cc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Hatua ya 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 1693966387d..545d5ddcd3d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Hatua ya 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 532636c5c24..01c426e728d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Hatua ya 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index afbb43adeed..8b3cb1b4f83 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Hatua ya 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index 767d8b54ea0..d9b122d8549 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Hatua ya 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 770301a6d04..0aa52253c4b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Hatua ya 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index ba57d13913c..2a72a101773 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Hatua ya 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index 3d3ca91d26c..f19e076fca6 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Hatua ya 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 9348aa86745..dc6d63565b3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Hatua ya 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index 74d3dce8c7f..a68f265ff2d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Hatua ya 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 7d85a73ea80..bf5ba8ab818 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Hatua ya 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index bc653e63158..a6b0501236d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Hatua ya 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 6f1a6822273..7efda9045cc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Hatua ya 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index ced6f61ae58..a4531f7b311 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Hatua ya 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 8346390d469..5874bb8eb4d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Hatua ya 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index 0b5ac927cd9..28877ef405a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Hatua ya 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index 73ccf3c4d71..d7376bb2d78 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Hatua ya 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index 7b5086a4db8..7fbf61939fb 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Hatua ya 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index 64cb5aa9fe0..9c4c2d9490f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Hatua ya 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index 68012f410fe..2d4ad2dc17c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Hatua ya 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index 28b4366d4c5..882f5359853 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Hatua ya 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 332687ab594..21101bab723 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Hatua ya 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index f3ad5beecf9..00176126504 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Hatua ya 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 4ac0cf851d0..26fa7e4c5ab 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Hatua ya 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index b2fc6afe9fe..1110cb36177 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Hatua ya 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index 5f974795464..0f20baeab9a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Hatua ya 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index 030af11225b..d13a7eb5ed3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Hatua ya 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 933ad991bf1..6daf63db3d9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Hatua ya 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index e920c12b940..9670a73667e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Hatua ya 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 5086af41627..c2f4268dba0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Hatua ya 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index 8d5bbbd537e..e647743e443 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Hatua ya 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index bcaf74e9bbc..71006ed6e31 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Hatua ya 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index c6f3b239a79..7739d08bdfc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Hatua ya 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index afbc0a5536d..be957205c33 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Hatua ya 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 7bb1f0a7ecf..d2904f5090e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Hatua ya 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index 707534d5655..b5af6d28b69 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Hatua ya 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index 60613651225..fd993364550 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Hatua ya 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index e567cdcd168..051e7974e36 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Hatua ya 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 86b41be465c..95438a380ba 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Hatua ya 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 410fe0e6382..f60366890bc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Hatua ya 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                            +

                                            freeCodeCamp Code Warrior

                                            +

                                            + Help the main player navigate to the yellow checkpoints. +

                                            +

                                            + Use the keyboard arrows to move the player around. +

                                            +

                                            You can also use the spacebar to jump.

                                            + +
                                            + +
                                            +
                                            + +
                                            +

                                            Congrats!

                                            +

                                            You reached the last checkpoint.

                                            +
                                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                            +

                                            freeCodeCamp Code Warrior

                                            +

                                            + Help the main player navigate to the yellow checkpoints. +

                                            +

                                            + Use the keyboard arrows to move the player around. +

                                            +

                                            You can also use the spacebar to jump.

                                            + +
                                            + +
                                            +
                                            + +
                                            +

                                            Congrats!

                                            +

                                            You reached the last checkpoint.

                                            +
                                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                            +

                                            freeCodeCamp Code Warrior

                                            +

                                            + Help the main player navigate to the yellow checkpoints. +

                                            +

                                            + Use the keyboard arrows to move the player around. +

                                            +

                                            You can also use the spacebar to jump.

                                            + +
                                            + +
                                            +
                                            + +
                                            +

                                            Congrats!

                                            +

                                            You reached the last checkpoint.

                                            +
                                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                            +

                                            freeCodeCamp Code Warrior

                                            +

                                            + Help the main player navigate to the yellow checkpoints. +

                                            +

                                            + Use the keyboard arrows to move the player around. +

                                            +

                                            You can also use the spacebar to jump.

                                            + +
                                            + +
                                            +
                                            + +
                                            +

                                            Congrats!

                                            +

                                            You reached the last checkpoint.

                                            +
                                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                            +

                                            freeCodeCamp Code Warrior

                                            +

                                            + Help the main player navigate to the yellow checkpoints. +

                                            +

                                            + Use the keyboard arrows to move the player around. +

                                            +

                                            You can also use the spacebar to jump.

                                            + +
                                            + +
                                            +
                                            + +
                                            +

                                            Congrats!

                                            +

                                            You reached the last checkpoint.

                                            +
                                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                            +

                                            freeCodeCamp Code Warrior

                                            +

                                            + Help the main player navigate to the yellow checkpoints. +

                                            +

                                            + Use the keyboard arrows to move the player around. +

                                            +

                                            You can also use the spacebar to jump.

                                            + +
                                            + +
                                            +
                                            + +
                                            +

                                            Congrats!

                                            +

                                            You reached the last checkpoint.

                                            +
                                            + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index d4f5c452787..dcddaf8b8bc 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- You should use `getElementById()` to access the `task-form` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `confirm-close-dialog` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `open-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 3b86da35b45..4087d980858 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y You should use `getElementById()` to access the `close-task-form-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `add-or-update-task-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `cancel-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 142aac41664..6deb86fef54 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us You should use `getElementById()` to access the `discard-btn` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `tasks-container` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `title-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index 8edbbc8d841..5087f2394e3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` You should use `getElementById()` to access the `date-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should use `getElementById()` to access the `description-input` element. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 058f7f3d88f..02ced468d01 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index f566945999c..e6c1685588d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index e826bbb481d..e1c8f5cc55e 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index c67b0260985..7cdeb08e9f1 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index 2e2a66182c1..312b5463f97 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index b94fb62f537..394029f77f1 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                                            /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                                            Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index 00b0950414c..6943d40ec3c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                                            .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                            Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index 0e3120cffac..8d63524a6b9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index 52662015216..0ec1fe24436 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 9ebb39e1e0a..f99de0a7201 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index d32773d8b3b..daea589a81b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index 37cdfe262be..5d8cf5c5e14 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index 00a2f569d91..95cbbc22cc5 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index 4d51361a570..e6c9ff983a8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index 213442be68d..114f2f694e9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                            Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                            Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                            Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                            Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                            Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                            Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index b6e0d25064a..d0e82f341a8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index 3bd24477dd7..3580e93f2ce 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 6e221522bb8..f4c85aa6a66 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index b447eacdaee..8353fae4c29 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index c173a9bfa4b..785d014f50b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index 868a7993571..1f1c2b64863 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index e5ed1776eb7..6ffe345d40f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index 8ea51b94d2c..7a822d8c5f1 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 0edabf81565..5d6dcc3d029 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 5f29db0c5f3..837e30a36c6 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 53a6aa28c3e..6f095a3236a 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index 7cc5e8b88de..3683ce2795d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index f0edb7ddb0c..fa98c37e928 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index 4c2aeb27f9b..581a95f1c9f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index 2cddda21e4f..346fe608023 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index c5286917c6a..338b469bd80 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index b114ac9a667..60602bb6460 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index fb6ab34bbcd..8f1456fee20 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index 97882eaf234..3266bb119a1 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index 74e9f28e815..932ba62645f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 5b0bc160f87..e199cee3f24 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                                            .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                            Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index eec1e882d7a..2ff6fe55caa 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index d5703264b3c..2a90d0aa441 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. All of the HTML and CSS for this project has been provided for you. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 71abe7b6670..48b1e2fcf30 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 6aabbbaf026..8ddd1e55b93 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 9321ff8a418..fa9500d33e3 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 7332c974b02..4e01b68928d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 2c6b2ae01d8..09052ae19c4 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index c170ef5a831..47601ed3603 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index eaa7a0670a6..5fa11b5e1e9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index 1528e85e8db..c81a15fc269 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index 5cd7ea1d6e4..0908f6cb530 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index dbeb80c7a4c..ef297926818 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 9a21ae45f28..0074a768ece 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 The next step would be to display the word `(Captain)` next to the player if they are listed as a captain for the team. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index d6d2d3bbba3..6b71d0acba0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index 0544b4bdd11..0985c4eaa7d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index a3caf074b5c..2e67714898d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index 303dace84dc..a4591333d51 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index b66de0298ec..56c3a78bdda 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index f6cb13c7bc5..035d72fa3f0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index 3ff1f2396c8..da8b840f22c 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index 11c8298ac82..d7a3ad7cf86 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 150f5b1a485..10689d4f6c2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 831aa380783..eebdad0117f 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index f1dbe181547..3d555b3a72d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index e9e5824a5df..6933307e6d0 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 40cf6798820..6545b7100d2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index 7b304b55777..9974aa5432b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 8cb5261aa8e..810a56c7dd2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index a05ffb2626b..94747c7fec7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index ebe2b87a69f..da3b2f4f7ee 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 08c78cf39f0..28d57753c6b 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index 3bfc78ae1f3..3b028e21923 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index 81834f564d9..0815cc9e763 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 89c1f7c0279..9b0698ebc44 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index ae0f66f9d74..2d8e975d7a9 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index c7e2e0eb7cd..e35cbb2a0e7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 64be7e94ece..d01da842a0d 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index 53554aa4167..92acd948b71 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` The body of your `.forEach()` method's callback function should be empty. diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index c8db9dff184..43d1ac214af 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Your `if` statement should exit the function execution. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 5aa2c8f5d47..f2f1f2b4720 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); You should use arrow syntax to assign `isSpam` a function. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isSpam` function should have a single `msg` parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Your `isSpam` function should implicitly return `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 8a870a20649..10c3ab793fe 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index cf38df95822..ea0a1db8be8 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index c374fbc08f7..cf8b53e6ae2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); You should not have a `console.log(formattedDate);` line in your code. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index 3817dbd1ef4..173dcd89fb2 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index a448714c2e4..745ab8f2e50 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 When the user chooses the `Year, Month, Day` option from the dropdown, the date format should reflect this choice. -To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `case123`: +To do this, you can add a `case` clause in the `switch` statement that checks for a match against the expression `expr`, followed by code to run if there's a match. Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Add a `case` where the value is `yyyy-mm-dd`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. +Add a `case` where the value is `"yyyy-mm-dd"`. Inside the `case`, set the text content of `currentDateParagraph` to the value of `formattedDate`. # --hints-- -You should add a `case` where the condition is `yyyy-mm-dd`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Then set the `textContent` property of `currentDateParagraph` equal to `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index fd7eb422553..fa2a4b2e6b7 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ Add a `break` statement to the end of your `case` block. You should add a `break` statement within the `case` after your logic. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index df7600fbf0a..743a1be74de 100644 --- a/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/swahili/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Add another `case` with the value `mm-dd-yyyy-h-mm`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. Inside that `case`, set the text content of `currentDateParagraph` to empty template literals. Also, make sure to include a `break` statement to terminate the `switch` statement. # --hints-- -You should add a `case` where the condition is `mm-dd-yyyy-h-mm`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex You should include a `break` statement within the `case` after your logic. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/swahili/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index 549eef0d99f..d5dc2506691 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                                            Creamy Chocolate Fudge

                                            - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                                            Description

                                            This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                                            This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                                            diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index e0a91b54e4a..d1ae38b2442 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ As you’ve seen, flexbox is not just a single CSS property but a whole toolbox A flex container is any element that has `display: flex` on it. A flex item is any element that lives directly inside of a flex container. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index 7e3b2d5d946..030a5142a4e 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Somewhat confusingly, any element can be both a flex container and a flex item. Said another way, you can also put `display: flex` on a flex item and then use flexbox to arrange its children. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Creating and nesting multiple flex containers and items is the primary way you will be building up complex layouts. The following image was achieved using only flexbox to arrange, size, and place the various elements. Flexbox is a very powerful tool. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index 2d214304d81..a454fd22fba 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ The `flex` declaration is actually a shorthand for 3 properties that you can set In this case, `flex` is actually a shorthand for `flex-grow`, `flex-shrink` and `flex-basis`. -flex shorthand +CSS code setting the flex property to 1 for a div element. In the above screenshot, `flex: 1` equates to: `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 6ab4cb1f90e..02bdcd20a2b 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ Adding `flex: 1` to `.item` makes each of the items grow to fill the available s Remove `flex: 1` from `.item` and add `justify-content: space-between` to `.container`. Doing so should give you something like this: -an image displaying three blue squares which are spread out over the entire width of it's container +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` aligns items across the **main axis**. There are a few values that you can use here. You'll learn the rest of them in the reading assignments, but for now try changing it to center, which should center the boxes along the main axis. diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index 9ea6a1913b4..f475b5ede38 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w To change the placement of items along the cross axis use `align-items`. Try getting the boxes to the center of the container by adding `align-items: center` to `.container`. The desired result looks like this: -an image displaying three blue squares which are centered in the middle of the flex container +three blue squares centered in the middle of the flex container Because `justify-content` and `align-items` are based on the main and cross axis of your container, their behavior changes when you change the flex-direction of a flex-container. For example, when you change `flex-direction` to `column`, `justify-content` aligns vertically and `align-items` aligns horizontally. The most common behavior, however, is the default, i.e. `justify-content` aligns items horizontally (because the main axis defaults to horizontal), and `align-items` aligns them vertically. One of the biggest sticking points that beginners have with flexbox is confusion when this behavior changes. diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/swahili/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 32861ac8835..185b29f5c52 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ Closing tags tell the browser where an element ends. They are almost the same as A full paragraph element looks like this: -element diagram +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/swahili/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/swahili/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/swahili/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/swahili/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a ` + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                          • + + +
                                          • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +--fcc-editable-region-- + +--fcc-editable-region-- + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md new file mode 100644 index 00000000000..b5bc352a862 --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65c6532520cf4f323329b2c6.md @@ -0,0 +1,653 @@ +--- +id: 65c6532520cf4f323329b2c6 +title: Step 28 +challengeType: 0 +dashedName: step-28 +--- + +# --description-- + +Right now the song order has not changed. That is because the updates you made using the `sort` method will not happen until the `sortSongs` function is called. + +Change your `renderSongs` function to call the `sortSongs` function. + +Now you should see the songs in alphabetical order. + +# --hints-- + +You should have `renderSongs(sortSongs())`. + +```js +assert.match(code, /renderSongs\(\s*sortSongs\(\s*\)\s*\)/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +

                                            freeCodeCamp

                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            + song cover art +
                                            +
                                            +
                                            +

                                            +

                                            +
                                            +
                                            + + + + + +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                            +

                                            Playlist

                                            +
                                            +
                                            +
                                            +
                                            +
                                            +
                                              +
                                              +
                                              + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                            • + + +
                                            • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); + + return userData?.songs; +}; + +--fcc-editable-region-- +renderSongs(userData?.songs); +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md new file mode 100644 index 00000000000..014eede970b --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-basic-string-and-array-methods-by-building-a-music-player/65cf1f2cd796c06057bf3f3c.md @@ -0,0 +1,648 @@ +--- +id: 65cf1f2cd796c06057bf3f3c +title: Step 27 +challengeType: 0 +dashedName: step-27 +--- + +# --description-- + +The last step for the `sortSongs` function is to return `userData?.songs`. + +# --hints-- + +You should return `userData?.songs` at the end of the `sortSongs` function. + +```js +assert.match(code, /return\s+userData\?\.songs\s*;?/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + + + + Learn Basic String and Array Methods by Building a Music Player App + + + + +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +

                                              freeCodeCamp

                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              + song cover art +
                                              +
                                              +
                                              +

                                              +

                                              +
                                              +
                                              + + + + + +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                              +

                                              Playlist

                                              +
                                              +
                                              +
                                              +
                                              +
                                              +
                                                +
                                                +
                                                + + + +``` + +```css +:root { + /* colors */ + --primary-color: #dfdfe2; + --secondary-color: #ffffff; + --app-background-color: #4d4d62; + --background-color: #1b1b32; + --foreground-color: #3b3b4f; + --highlight-color: #f1be32; + + /* font sizes */ + --root-font-size: 16px; + font-size: var(--root-font-size); + + /* font-families */ + --font-headline: "Roboto Mono", monospace; + --font-family: "Lato", sans-serif; +} + +*, +*::after, +*::before { + box-sizing: border-box; +} + +body { + background-color: var(--app-background-color); + color: var(--primary-color); + font-family: var(--font-family); +} + +h1 { + font-size: 1.125rem; + line-height: 1.6; +} + +h2 { + font-size: var(--root-font-size); +} + +ul { + margin: 0; +} + +.container { + margin-top: 10px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + row-gap: 5px; +} + +.player, +.playlist { + width: 450px; + background-color: var(--background-color); + border: 3px solid var(--foreground-color); +} + +.player { + height: 260px; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +.player-bar, +.playlist-bar { + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 5px; + width: 100%; + height: 30px; + background-color: var(--foreground-color); +} + +.parallel-lines { + display: flex; + flex-wrap: wrap; + row-gap: 6px; + padding: 0 5px; +} + +.parallel-lines > div { + height: 2px; + width: 100%; + min-width: 75px; + background-color: var(--highlight-color); +} + +.fcc-title, +.playlist-title { + color: var(--secondary-color); + margin: 0 10px; + font-family: var(--font-headline); +} + +.player-content { + display: flex; + background-color: var(--foreground-color); + width: 430px; + height: 200px; + column-gap: 13px; + align-items: center; + justify-content: center; +} + +#player-album-art { + background-color: var(--secondary-color); + border: 6px solid var(--background-color); +} + +#player-album-art img { + width: 150px; + display: block; +} + +.player-display { + display: flex; + flex-direction: column; + row-gap: 20px; + padding: 14px; + background-color: var(--background-color); + height: 153px; + width: 226px; +} + +.player-display-song-artist { + height: 80px; +} + +.player-buttons svg { + fill: var(--primary-color); +} + +.playing > svg { + fill: var(--highlight-color); +} + +.player-buttons { + display: flex; + justify-content: space-around; +} + +button { + background: transparent; + border: none; + color: var(--primary-color); + cursor: pointer; + font-size: var(--root-font-size); + outline-color: var(--highlight-color); + text-align: center; +} + +.playlist-song { + outline-color: var(--highlight-color); +} + +.playlist li:not(:last-child) { + border-bottom: 1px solid var(--background-color); +} + +button:focus, +.playlist-song:focus { + outline-style: dashed; + outline-width: 2px; +} + +/* Playlist */ +.playlist { + height: auto; + padding: 10px; + display: flex; + flex-direction: column; + align-items: center; + row-gap: 10px; +} + +#playlist-songs { + width: 430px; + height: 100%; + background-color: var(--foreground-color); + display: flex; + flex-direction: column; + row-gap: 8px; + padding: 8px 9px; + visibility: visible; + justify-content: start; + list-style: none; +} + +.playlist-song { + display: flex; + height: 55px; + justify-content: space-between; + align-items: center; + padding: 5px; +} + +[aria-current="true"] { + background-color: var(--background-color); +} + +[aria-current="true"] p { + color: var(--highlight-color); +} + +.playlist-song-info { + height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: space-around; + column-gap: 7px; + padding: 5px 0; + font-family: var(--font-family); +} + +#player-song-title, +#player-song-artist { + margin: 0; +} + +#player-song-artist { + color: var(--highlight-color); + font-size: 0.75rem; +} + +#player-song-title { + font-size: 1.125rem; +} + +.playlist-song-title { + font-size: 0.85rem; + width: 241px; + text-align: left; +} + +.playlist-song-artist { + font-size: 0.725rem; + width: 80px; +} + +.playlist-song-duration { + font-size: 0.725rem; + margin: auto; + font-family: var(--font-headline); + width: 30px; +} + +.playlist-song-delete { + padding: 0; + width: 20px; + height: 20px; +} + +.playlist-song-delete, +.playlist-song-delete { + fill: var(--foreground-color); +} + +.playlist-song-delete:hover circle, +.playlist-song-delete:focus circle { + fill: #ff0000; +} + +@media (max-width: 700px) { + .player, + .playlist { + width: 300px; + } + + .player { + height: 340px; + } + + #playlist-songs { + height: 280px; + padding: 5px 6px; + overflow-y: scroll; + overflow-x: hidden; + scrollbar-color: var(--background-color) var(--secondary-color); + scrollbar-width: thin; + } + + #playlist-songs::-webkit-scrollbar { + width: 5px; + } + + #playlist-songs::-webkit-scrollbar-track { + background: var(--background-color); + } + + #playlist-songs::-webkit-scrollbar-thumb { + background: var(--secondary-color); + } + + h1 { + font-size: 0.813rem; + } + + h2 { + font-size: 0.75rem; + } + + .player-bar, + .playlist-bar, + .player-content, + #playlist-songs { + width: 280px; + } + + .playlist-song { + justify-content: space-between; + } + + .playlist-song-title { + width: 140px; + } + + .playlist-song-artist { + width: 40px; + } + + .playlist-song-duration > button { + padding: 0; + } + + .player-content { + display: inline; + position: relative; + justify-items: center; + height: 100%; + } + + #player-album-art { + z-index: -100; + height: 280px; + box-shadow: none; + background: #000; + } + + #player-album-art img { + width: 100%; + opacity: 0.6; + } + + .player-display-song-artist { + padding: 0 10px; + } + + .player-display-song-artist > p { + white-space: pre-wrap; + } + + .player-display { + position: absolute; + width: 100%; + z-index: 1000; + background-color: transparent; + top: 0; + height: 280px; + justify-content: space-between; + text-align: center; + } +} +``` + +```js +const playlistSongs = document.getElementById("playlist-songs"); +const playButton = document.getElementById("play"); +const pauseButton = document.getElementById("pause"); +const nextButton = document.getElementById("next"); +const previousButton = document.getElementById("previous"); +const shuffleButton = document.getElementById("shuffle"); + +const allSongs = [ + { + id: 0, + title: "Scratching The Surface", + artist: "Quincy Larson", + duration: "4:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/scratching-the-surface.mp3", + }, + { + id: 1, + title: "Can't Stay Down", + artist: "Quincy Larson", + duration: "4:15", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stay-down.mp3", + }, + { + id: 2, + title: "Still Learning", + artist: "Quincy Larson", + duration: "3:51", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/still-learning.mp3", + }, + { + id: 3, + title: "Cruising for a Musing", + artist: "Quincy Larson", + duration: "3:34", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cruising-for-a-musing.mp3", + }, + { + id: 4, + title: "Never Not Favored", + artist: "Quincy Larson", + duration: "3:35", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/never-not-favored.mp3", + }, + { + id: 5, + title: "From the Ground Up", + artist: "Quincy Larson", + duration: "3:12", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/from-the-ground-up.mp3", + }, + { + id: 6, + title: "Walking on Air", + artist: "Quincy Larson", + duration: "3:25", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/walking-on-air.mp3", + }, + { + id: 7, + title: "Can't Stop Me. Can't Even Slow Me Down.", + artist: "Quincy Larson", + duration: "3:52", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/cant-stop-me-cant-even-slow-me-down.mp3", + }, + { + id: 8, + title: "The Surest Way Out is Through", + artist: "Quincy Larson", + duration: "3:10", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/the-surest-way-out-is-through.mp3", + }, + { + id: 9, + title: "Chasing That Feeling", + artist: "Quincy Larson", + duration: "2:43", + src: "https://s3.amazonaws.com/org.freecodecamp.mp3-player-project/chasing-that-feeling.mp3", + }, +]; + +const audio = new Audio(); + +let userData = { + songs: [...allSongs], + currentSong: null, + songCurrentTime: 0, +}; + +const renderSongs = (array) => { + const songsHTML = array + .map((song)=> { + return ` +
                                              • + + +
                                              • + `; + }) + .join(""); + + playlistSongs.innerHTML = songsHTML; +}; + +const sortSongs = () => { + userData?.songs.sort((a,b) => { + if (a.title < b.title) { + return -1; + } + + if (a.title > b.title) { + return 1; + } + + return 0; + }); +--fcc-editable-region-- + +--fcc-editable-region-- +}; + +renderSongs(userData?.songs); +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md index 7a5fbc20731..26b2f0a2b61 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da3c6b6fbd742bff6ee40.md @@ -28,7 +28,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `fetch` call. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md index 4b8a1524daa..0d24527afe4 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da42481d90c4314c99e94.md @@ -57,7 +57,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*console\.log\(\s*res\s*\)\s*\)\s*;/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md index 72e6ad1acbc..efd619605cd 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da465273051435d332b15.md @@ -28,7 +28,7 @@ assert.match(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)/ You should not have a semi-colon after your `.then()`. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md index d80e03c1e17..87b2e2d45e3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da4b16937be43ba24c63d.md @@ -23,7 +23,7 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your first `.then()` should not have a semi-colon. ```js -assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\);/) +assert.notMatch(code, /\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*;/) ``` You should chain another `.then()` to the existing `.then()`. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md index 65f1de9dbfa..55156e4dee7 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da51a9810e74411262fcc.md @@ -48,37 +48,37 @@ assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculu Your second `.then()` method should log `data` to the console. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)/) ``` Your second `.then()` should not have a semicolon. ```js -assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\);/) +assert.notMatch(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\s*;/) ``` You should chain the `.catch()` method to the second `.then()` you already have. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(/) ``` You should add an `err` parameter to your `.catch()` method. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)/) ``` Your `.catch()` method should have an arrow function syntax. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?/) ``` Your `.catch()` method should use `console.error()` to log `err` to the console with the text `` `There was an error: ${err}` ``. Don't forget to use backticks. ```js -assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\);?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\);?\n?(\s*)?\}?\s*\)\s*;?/) +assert.match(code, /fetch\(\s*('|"|`)https:\/\/cdn\.freecodecamp\.org\/curriculum\/news\-author\-page\/authors\.json\1\s*\)\s*\.then\(\s*(\(\s*res\s*\)|res)\s*=>\s*res\.json\(\s*\)\s*\)\s*\.then\(\s*(\(\s*data\s*\)|data)\s*=>\s*\{\s*\n?\s*?console\.log\(\s*data\s*\)\s*;?\n?\s*\}\s*\)\n?\s*\.catch\(\s*(\(\s*err\s*\)|err)\s*=>\s*\{?\n?(\s*)?console\.error\(\s*`There\swas\san\serror:\s?\$\{\s*err\s*\}`\s*\)\s*;?\n?(\s*)?\}?\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md index 3c1dd38d289..f65208da5b3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5462576784453146ec2.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+startingIndex/) You should set your `startingIndex` variable to `0`. ```js -assert.match(code, /let\s+startingIndex\s*=\s*0;?/) +assert.match(code, /let\s+startingIndex\s*=\s*0\s*;?/) ``` Використайте `let`, щоб оголосити змінну під назвою `endingIndex`. @@ -36,7 +36,7 @@ assert.match(code, /let\s+endingIndex/) You should set your `endingIndex` variable to `8`. ```js -assert.match(code, /let\s+endingIndex\s*=\s*8;?/) +assert.match(code, /let\s+endingIndex\s*=\s*8\s*;?/) ``` Використайте `let`, щоб оголосити змінну під назвою `authorDataArr`. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md index 110d6c97978..f1596f71d8b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da5abaac81844a54adb03.md @@ -40,7 +40,7 @@ assert.match(code, /const\s+displayAuthors\s*=\s*\(?\s*authors/) Функція `displayAuthors` повинна бути порожньою. ```js -assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\};?/) +assert.match(code, /const\s+displayAuthors\s*=\s*(\(\s*authors\s*\)|authors)\s*=>\s*\{\n?\s*?\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md index c8978ebe028..0b15009cc8a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da615af82bf454215a992.md @@ -34,7 +34,7 @@ assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*/) Функція зворотного виклику має бути порожньою. ```js -assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\);?/) +assert.match(code, /authors\.forEach\(\s*\(\s*\{.*\}\s*,\s*index\s*\)\s*=>\s*\{\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md index fdaf4d87d8b..9d98904832a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da6570acf7545931ce477.md @@ -23,7 +23,7 @@ assert.match(code, /authorContainer\.innerHTML\s*/) You should use compound assignment to append an empty template literal to the `innerHTML` of `authorContainer`. ```js -assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`;?/) +assert.match(code, /authorContainer\.innerHTML\s*\+=\s*`\s*\n?\s*`\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md index e18fe541be7..5838c052f73 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da73b09e7f046c758e0ed.md @@ -16,13 +16,13 @@ First, remove your `console.log()` statement. Then, assign `data` to the `author You should remove the console log showing the `data`. ```js -assert.notMatch(code, /console\.log\(\s*data\s*\);/) +assert.notMatch(code, /console\.log\(\s*data\s*\)\s*;?/) ``` You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md index 9016497befe..c7dfb94fc93 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da791d0c34a472b8d15b6.md @@ -16,7 +16,7 @@ Inside your `console.log()` statement, add the text `Author Data Array:` as the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should have a console log with the text `Author Data Array:`. @@ -34,7 +34,7 @@ assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,/) `authorDataArr` should be the second argument of your console log statement. ```js -assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.match(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md index 6f2cff7ea02..3a837f2fc60 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da7bfbc7f0f477438ad8a.md @@ -16,13 +16,13 @@ First, remove the console log statement showing `authorDataArr`. Then, call the You should assign `data` to the `authorDataArr` variable ```js -assert.match(code, /authorDataArr\s*=\s*data;?/) +assert.match(code, /authorDataArr\s*=\s*data\s*;?/) ``` You should remove the console log statement showing `authorDataArr` ```js -assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\);?/) +assert.notMatch(code, /console\.log\(\s*("|'|`)Author\s+Data\s+Array:\s*\1\s*,\s*authorDataArr\s*\)\s*;?/) ``` You should call your `displayAuthors` function. @@ -46,7 +46,7 @@ assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex/) The second parameter of your `slice()` method should be `endingIndex`. ```js -assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\);?/) +assert.match(code, /displayAuthors\(\s*authorDataArr\.slice\(\s*startingIndex\s*,\s*endingIndex\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md index cb79aaacc85..a1263cc4dba 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da8db2a036048ebe6999e.md @@ -14,13 +14,13 @@ Inside the `fetchMoreAuthors` function, set the `startingIndex` and `endingIndex You should set the `startingIndex` variable to `+=8`. ```js -assert.match(code, /startingIndex\s*\+=\s*8;?/) +assert.match(code, /startingIndex\s*\+=\s*8\s*;?/) ``` You should set the `endingIndex` variable to `+=8`. ```js -assert.match(code, /endingIndex\s*\+=\s*8;?/) +assert.match(code, /endingIndex\s*\+=\s*8\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md index 07037b85487..bc97be8bfaa 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641da9aceb788e49a73ebcc9.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1/) Your event listener should take `fetchMoreAuthors` as the function to run. ```js -assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\);?/) +assert.match(code, /loadMoreBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*fetchMoreAuthors\s*\)\s*;?/) ``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md index 8ac4894bcfa..bb4858372b6 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daa5ea050f24a7cade6e6.md @@ -14,13 +14,13 @@ If this condition is met, disable the button by setting its `disabled` property You should set the `disabled` property of `loadMoreBtn` to `true`. ```js -assert.match(code, /loadMoreBtn\.disabled\s*=\s*true;?/) +assert.match(code, /loadMoreBtn\.disabled\s*=\s*true\s*;?/) ``` You should set the `textContent` of `loadMoreBtn` to `No more data to load`. ```js -assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1;?/) +assert.match(code, /loadMoreBtn\.textContent\s*=\s*('|"|`)No\s+more\s+data\s+to\s+load\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md index 853f69e8b24..67fa762cd4e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641daae5e18eae4b562633e4.md @@ -16,7 +16,7 @@ Inside the `.catch()`, remove the `console.error()` and set the `innerHTML` of t You should remove your `console.error` and its text. ```js -assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\);/) +assert.notMatch(code, /console\.error\(\s*`There\s+was\s+an\s+error:\s+\$\{err\}`\s*\)\s*;?/) ``` You should access the `innerHTML` of `authorContainer` and set it to a `p` element. Don't forget to surround the `p` element with a template literal. @@ -35,7 +35,7 @@ assert.match(code, /(`|"|')/) Your `p` element should have the text `There was an error loading the authors`. ```js -assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1;?/) +assert.match(code, /(`|"|')There\s+was\s+an\s+error\s+loading\s+the\s+authors<\/p>\1\s*;?/) ``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md index 8cb595c175f..f21635e346a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-fetch-and-promises-by-building-an-fcc-authors-page/641dab13c1b6f14b9828e6b1.md @@ -30,7 +30,7 @@ assert.match(code, /loadMoreBtn\.style\.cursor/) You should set the value of the `cursor` property to `not-allowed`. ```js -assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1;?/) +assert.match(code, /loadMoreBtn\.style\.cursor\s*=\s*('|"|`)not\-allowed\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md index be683139c87..7e1d609b406 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9bcc26219e7090da0f549.md @@ -16,13 +16,13 @@ Still within your `if` block, set `isError` to `true` and return `null`. After your `alert`, you should set `isError` to `true`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true/); ``` After you modify `isError`, you should `return` the value `null`. ```js -assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\);\s*isError\s*=\s*true;?\s*return\s+null;?\s*\}/); +assert.match(code.split(/function\s+getCaloriesFromInputs/)[1], /alert\(\s*`Invalid Input: \${invalidInputMatch\s*\[\s*0\s*\]\s*}`\s*\)\s*;?\s*isError\s*=\s*true\s*;?\s*return\s+null\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md index fd70148d032..07043e9e13c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e45519caf31b987fbb5f.md @@ -26,7 +26,7 @@ assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)/); Your `if` statement should use `return` to end the function execution. ```js -assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return;?\s*\}?\s*/); +assert.match(calculateCalories.toString(), /if\s*\(\s*isError\s*\)\s*\{?\s*return\s*;?\s*\}?\s*/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md index 22818d3d9a2..175959130d2 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-form-validation-by-building-a-calorie-counter/63c9e5eea8261d22856ead1c.md @@ -21,7 +21,7 @@ You should assign an empty template literal to the `innerHTML` property of the ` ```js // again, template literals don't play well with the parser so we have to look at the raw code. -const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/;?\s*\}/)[0]; +const htmlString = code.split(/output\s*\.\s*innerHTML\s*=\s*/)[1].split(/\s*;?\s*\}/)[0]; assert.equal(htmlString, '``'); ``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md index 40601da1ffd..baf124de2e0 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642dccb78549c9285835ebc2.md @@ -24,37 +24,37 @@ const outer = () => { Оголосіть змінну `createLabel` у функції `onload`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?)?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*(?:const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?)?\s*(?:let|var|const)\s+createLabel/); ``` Оголосіть змінну `createLabel` після змінної `container`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*(?:let|var|const)\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*(?:let|var|const)\s+createLabel/); ``` Змінна `createLabel` має бути оголошеною за допомогою `const`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel/); ``` Змінна `createLabel` має бути стрілковою функцією. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Функція `createLabel` повинна мати параметр `name`. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>/); ``` Функція `createLabel` має бути порожньою. ```js -assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\);?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); +assert.match(code, /window\.onload\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+container\s*=\s*document\.getElementById\(\s*('|"|`)container\1\s*\)\s*;?\s*const\s+createLabel\s*=\s*(\(\s*name\s*\)|name)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md index 7abfa8d37d1..427a9ce3c6a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/642df32c0c2db433d8b46d46.md @@ -26,7 +26,7 @@ assert.match(code, /container\.appendChild\(\s*label\s*\)/); You should append `label` after setting the attributes. ```js -assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\);?\s*label\.className\s*=\s*('|"|`)label\2;?\s*label\.textContent\s*=\s*name;?\s*container\.appendChild\(\s*label\s*\)/); +assert.match(code, /const\s+label\s*=\s*document\.createElement\(\s*('|"|`)div\1\s*\)\s*;?\s*label\.className\s*=\s*('|"|`)label\2\s*;?\s*label\.textContent\s*=\s*name\s*;?\s*container\.appendChild\(\s*label\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md index 60e47796a10..daff5910caf 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434750c53db16218f41e6e1.md @@ -40,13 +40,13 @@ assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(/); Передайте функцію зворотного виклику до `.forEach()`, використовуючи стрілковий синтаксис. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?.*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція зворотного виклику повинна мати `number` як єдиний параметр. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md index 066ecf08fcd..bb584573c59 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6434759f78ec812264ff8f34.md @@ -16,13 +16,13 @@ Then call the `.forEach()` method on your `letters` array. Pass an empty callbac You should call your `createLabel()` function. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/); +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/); ``` Передайте `number` до виклику `createLabel()`. ```js -assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*\(?\s*number\s*\)?\s*=>\s*\{\s*createLabel\(/) +assert.match(code, /range\(\s*1\s*,\s*99\s*\)\.forEach\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*createLabel\(/) ``` You should call the `.forEach()` method on your `letters` array. @@ -34,13 +34,13 @@ assert.lengthOf(code.match(/letters\.forEach\(/g), 2) You should pass a callback function with arrow syntax to your `.forEach()` method. ```js -assert.match(code, /letters\.forEach\(\s*\(?.*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\([^)]*\)|[^\s()]+)\s*=>\s*\{/) ``` Функція зворотного виклику повинна мати параметр `letter`. ```js -assert.match(code, /letters\.forEach\(\s*\(?\s*letter\s*\)?\s*=>\s*\{/) +assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{/) ``` Функція зворотного виклику має бути порожньою. @@ -52,7 +52,7 @@ assert.match(code, /letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\ Your `letters.forEach()` callback function should be nested inside the `range(1, 99).forEach(number => {}` callback function. ```js -assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*\}\s*\)/) +assert.match(code, /range\s*\(\s*1\s*,\s*99\s*\)\s*.forEach\s*\(\s*(\(\s*number\s*\)|number)\s*=>\s*\{\s*[^}]*letters\.forEach\(\s*(\(\s*letter\s*\)|letter)\s*=>\s*\{\s*\}\s*\)\s*;?\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md index d0f8e66fce5..7bce57f00ec 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643498755d54c6279ba09078.md @@ -34,25 +34,25 @@ assert.isFunction(sum); Функція `sum` повинна використовувати стрілковий синтаксис. ```js -assert.match(code, /const\s+sum\s*=\(?.*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція `sum` повинна мати параметр `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>/); ``` Функція `sum` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Функція `sum` має повернути результат виклику `.reduce()` на `nums`. ```js -assert.match(code, /const\s+sum\s*=\s*\(?\s*nums\s*\)?\s*=>\s*nums\.reduce\(/); +assert.match(code, /const\s+sum\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\.reduce\(/); ``` Your `sum` function should return the sum of all numbers in `nums`. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md index f504c26d5c4..dfda333e53a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437124c4c03dd4c8fb35d56.md @@ -32,13 +32,13 @@ assert.isFunction(isEven); Функція `isEven` повинна використовувати стрілковий синтаксис. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `isEven` function should have a `num` parameter. ```js -assert.match(code, /const\s+isEven\s*=\s*\(?\s*num\s*\)?\s*=>/); +assert.match(code, /const\s+isEven\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your `isEven` function should use the modulo operator `%`. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md index 5239f812b5e..eb2f3c87a7d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6437133052eaf04d7300e622.md @@ -34,19 +34,19 @@ assert.isFunction(average); Функція `average` повинна використовувати стрілковий синтаксис. ```js -assert.match(code, /const\s+average\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+average\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція `average` повинна мати параметр `nums`. ```js -assert.match(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Функція `average` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+average\s*=\s*\(?\s*nums\s*\)?\s*=>\s*{/); +assert.notMatch(code, /const\s+average\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*{/); ``` Your `average` function should return the average value of the `nums` array. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md index 40f6b730a47..6fe32e7cb9f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/643715013330824ecaa70442.md @@ -42,43 +42,43 @@ assert.match(code, /const\s+median\s*=\s*\(?/); Функція `median` повинна мати параметр `nums`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)/); ``` Функція `median` не повинна використовувати неявне повернення. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/); ``` Функція `median` повинна мати змінну `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*(?:let|var|const)\s+sorted/); ``` Використайте `const`, щоб оголосити змінну `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted/); ``` You should use `.slice()` to assign a copy of the `nums` array to `sorted`. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)/); ``` You should chain the `.sort()` method to your `.slice()` method. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(/); ``` You should pass a callback function to your `sort` method to accurately sort the numbers in ascending order. Use an implicit return for clarity. ```js -assert.match(code, /const\s+median\s*=\s*\(?\s*nums\s*\)?\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); +assert.match(code, /const\s+median\s*=\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md index bcc7f84d858..0c40bdd9f5b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d1e5af8c0148fbef96d.md @@ -26,31 +26,31 @@ assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*n You should assign the length of the `sorted` array to your `length` variable. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?/); ``` Оголосіть змінну `middle` після змінної `length`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*(?:var|let|const)\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*(?:var|let|const)\s+middle/); ``` Використайте `const`, щоб оголосити змінну `middle`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle/); ``` You should assign `middle` the value of dividing your `length` variable by `2`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2/); ``` You should subtract `1` from your `length / 2` calculation. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md index aff5f25e172..281561e8ef3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496d80bc174a158c973080.md @@ -14,55 +14,55 @@ Using ternary syntax, check if `length` is even using your `isEven` function. If You should use the `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return/); ``` You should call your `isEven()` function after your `return` keyword. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(/); ``` Передайте змінну `length` до виклику `isEven()`. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)/); ``` You should use ternary syntax to check the truthiness of your `isEven()` call. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?/); ``` If the ternary is truthy, you should call your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(/); ``` You should pass an array to your `average()` function. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[/); ``` The first element of the array passed to `average()` should be the element at the `middle` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]/); ``` The first element of the array passed to `average()` should be the element at the `middle + 1` index of your `sorted` array. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)/); ``` If the ternary is false, you should return the value of `sorted` at the `middle` index. Use `Math.ceil()` to round the `middle` value up. ```js -assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); +assert.match(code, /const\s+median\s*=\s*nums\s*=>\s*\{\s*const\s+sorted\s*=\s*nums\.slice\(\s*\)\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\)\s*\s*;?\s*const\s+length\s*=\s*sorted\.length\s*;?\s*const\s+middle\s*=\s*length\s*\/\s*2\s*-\s*1\s*;?\s*return\s+isEven\(\s*length\s*\)\s*\?\s*average\(\s*\[\s*sorted\s*\[\s*middle\s*\]\s*,\s*sorted\s*\[\s*middle\s*\+\s*1\s*\]\s*\]\s*\)\s*:\s*sorted\s*\[\s*Math\.ceil\(\s*middle\s*\)\s*\]\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md index 4306defe74e..6cdf56e3bba 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64496e9c6d7a2e189948e441.md @@ -32,13 +32,13 @@ assert.isFunction(update); Функція `update` має приймати параметр `event`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>/); ``` Функція `update` має бути порожньою. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md index 6accf7b52a3..b0123181ab7 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449755666005520330cec5b.md @@ -16,19 +16,19 @@ The `target` property of the change event represents the element that changed. A Оголосіть змінну `element` у функції `update`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*(?:var|let|const)\s+element/); ``` Використайте `const`, щоб оголосити змінну `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element/); +assert.match(code, /const\s+update\s*=\s*(\(?\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element/); ``` You should assign the `target` property of the `event` parameter to your `element` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md index c1558e0f292..887abff47ff 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497da4062602213ecf32e7.md @@ -16,43 +16,43 @@ Assign the `value` property of `element` to a new variable called `value`, and u Оголосіть змінну `value` після змінної `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*(?:const|let|var)\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*(?:const|let|var)\s+value/); ``` Використайте `const`, щоб оголосити змінну `value`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value/); ``` You should assign the `value` property of `element` to your `value` variable. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value/); ``` You should call the `.replace()` method on the `value` property of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(/); ``` You should pass a regular expression to match whitespace to your `.replace()` method. Use the `\s` character class. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\//); ``` You should make your regular expression global. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); +assert.match(code, /const\s+update\s*=\s*(\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g/); ``` Передайте порожній рядок як другий аргумент до методу `.replace()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md index 7546e931f39..1d285f83d7c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497de936a2f322327e5c58.md @@ -14,19 +14,19 @@ Now you need to check if the `value` does not include the `id` of the element. C You should create an `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(/); ``` Your `if` condition should check if `value` includes the `id` of the `element`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)/); ``` Your `if` block should be empty. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*!value\.includes\(\s*element\.id\s*\)\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md index 6597e572b61..b7e79cc7e14 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64497e0e5e5a2c2329785af4.md @@ -16,7 +16,7 @@ Use the `&&` operator to add a second condition to your `if` statement that also You should use the `&&` operator to add a second condition to your `if` statement that also checks if the first character of `value` is `=`. You may use `[0]`, `.startsWith()`, or `.charAt(0)`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md index b0db5ebae64..0e1e2877669 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449842c6f6c84261075e4c9.md @@ -28,43 +28,43 @@ assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s Змінна `idToText` має бути стрілковою функцією. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція `idToText` повинна мати параметр `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>/); ``` You should assign `idToText` the result of calling the `.find()` method on your `cells` array. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(/); ``` Передайте функцію зворотного виклику до методу `.find()`. Use arrow syntax. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція зворотного виклику повинна мати параметр `cell`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>/); ``` Функція зворотного виклику має використати неявне повернення. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*\{/); ``` Your callback function should return whether `cell.id` is strictly equal to `id`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md index ecf24257cec..a6f96acd77a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498473a17adc26ef0ecc2d.md @@ -14,7 +14,7 @@ Your `idToText` function currently returns an `input` element. Update it to retu You should return the `value` property of the return value of the `.find()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md index e276875bcaa..98c1959cbae 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449849b78f43527be1e8a98.md @@ -16,38 +16,38 @@ Start by declaring a `rangeRegex` variable and assign it a regular expression th Оголосіть змінну `rangeRegex` після функції `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*(?:var|let|const)\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*(?:var|let|const)\s+rangeRegex/); ``` Використайте `const`, щоб оголосити змінну `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex/); ``` Змінна `rangeRegex` має бути регулярним виразом. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/.*\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/.*\/\s*;?/); ``` Your `rangeRegex` should use a capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(.*\)\/\s*;?/); ``` Your `rangeRegex` should use a character class in the capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[.*\]\)\/\s*;?/); ``` Your `rangeRegex` should use a character class to match `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md index 165f495afe8..2b67df35a3b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498542cab69128ab24e4de.md @@ -16,37 +16,37 @@ Add a capture group after your letter capture group. Your new capture group shou You should add a second capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(.*\)\/\s*;?/); ``` Your second capture group should have a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\??\)\/\s*;?/); ``` Your second capture group should have two character classes. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[.*\]\[.*\]\??\)\/\s*;?/); ``` Your first new character class should match the digits `1` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[.*\]\??\)\/\s*;?/); ``` Your second new character class should match the digits `0` through `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\??\)\/\s*;?/); ``` Your second new character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md index 47f8a35f110..4ee9f599847 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449860d84c9e22cbd7b497c.md @@ -14,7 +14,7 @@ Ranges are separated by a colon. After your two capture groups, your `rangeRegex You should add a colon after your second capture group. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/;?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md index 46752a344ca..a62367dc01c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449863f592af72d9be0959e.md @@ -16,31 +16,31 @@ Copy your two existing capture groups and paste them after the colon. You should add a third capture group to your `rangeRegex`, after the colon. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(.*\)/); ``` Your third capture group should use a character class. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[.*\]\)/); ``` Your third capture group should match the characters `A` through `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)/); ``` You should add a fourth capture group to your `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(.*\)/); ``` Your fourth capture group should match one or two digits. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md index ac913afa608..f327d1d31ca 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449874d5191562eb3313b3f.md @@ -14,19 +14,19 @@ Finally, make your `rangeRegex` global and case-insensitive. Your `rangeRegex` should be case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/g?i/); ``` Your `rangeRegex` should be global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/i?g/); ``` Your `rangeRegex` should be both global and case-insensitive. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md index 35fbf569807..706782461ac 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6449876e7aae0d2f8257a497.md @@ -16,55 +16,55 @@ To be safe, parse `num1` and `num2` into integers as you pass them into `range`. Оголосіть змінну `rangeFromString` після `rangeRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*(?:var|let|const)\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*(?:var|let|const)\s+rangeFromString/); ``` Використайте `const`, щоб оголосити змінну `rangeFromString`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString/); ``` Змінна `rangeFromString` має бути стрілковою функцією. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(.*\)\s*=>/); ``` Функція `rangeFromString` повинна мати `num1` як перший параметр. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1/); ``` Функція `rangeFromString` повинна мати `num2` як другий параметр. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>/); ``` Функція `rangeFromString` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Функція `rangeFromString` має повернути результат виклику функції `range`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(/); ``` You should call `parseInt` with `num1` as an argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)/); ``` You should call `parseInt` with `num2` as the argument and pass the result to the `range` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md index 9202e427549..e54313ade8b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/64498b085028fc30a58bb6a7.md @@ -14,31 +14,31 @@ Declare a function `elemValue` which takes a `num` parameter. Функція м Оголосіть змінну `elemValue` після функції `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*(?:var|let|const)\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+elemValue/); ``` Використайте `const`, щоб оголосити змінну `elemValue`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue/); ``` Змінна `elemValue` має бути стрілковою функцією. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Функція `elemValue` повинна мати `num` як єдиний параметр. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>/); ``` Функція `elemValue` має бути порожньою. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md index 1f7da728daf..b9414032364 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0889c6ff4baa46ac1c50.md @@ -16,37 +16,37 @@ Then, return your `inner` function. Оголосіть змінну `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*(?:var|let|const)\s+inner/); ``` Використайте `const`, щоб оголосити змінну `inner`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner/); ``` Змінна `inner` має бути стрілковою функцією. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Функція `inner` повинна мати `character` як єдиний параметр. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>/); ``` Функція `inner` має бути порожньою. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}/); ``` You should explicitly return your `inner` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*\}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md index ae88b5cf68d..fb490b85a7a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d09a07241aaab1e777080.md @@ -14,19 +14,19 @@ In your `inner` function, return the result of calling `idToText` with `characte Your `inner` function should use an explicit return. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return/); ``` Функція `inner` має повернути результат виклику функції `idToText`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(/); ``` You should pass `character + num` as the argument to your `idToText` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md index 71502e6e0c0..693fe8e3b40 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0a022da7bcabf3e3aca3.md @@ -25,31 +25,31 @@ You'll get some more practice with this. Declare a function called `addCharacter Оголосіть змінну `addCharacters`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*(?:var|let|const)\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*(?:var|let|const)\s+addCharacters/); ``` Використайте `const`, щоб оголосити змінну `addCharacters`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters/); ``` Змінна `addCharacters` має бути стрілковою функцією. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>/); ``` Функція `addCharacters` не повинна використовувати неявне повернення. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(.*\)|[^\s()]+)\s*=>\s*\{/); ``` Функція `addCharacters` повинна мати параметр `character1`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md index 17f0d9488a9..193de40a56d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0d20108440acc95a6b32.md @@ -20,19 +20,19 @@ const curry = soup => veggies => {}; Функція `addCharacters` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|characters1)\s*=>\s*\{/); ``` Your `addCharacters` function should return an arrow function which has a `character2` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>/); ``` Your inner arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md index 470cf10c0b8..a9068a98260 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0db5175974ad8633b71c.md @@ -14,13 +14,13 @@ Your inner functions can also return a function. Using the same arrow syntax, up Your inner arrow function should return another arrow function with a `num` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>/); ``` Your inner-most arrow function should be empty. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md index 715aaaa2379..b578a60df1a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d0e4636e14eae2bb3b992.md @@ -14,25 +14,25 @@ Now update your innermost function in the `addCharacters` chain to implicitly re Your innermost function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your innermost function should return the result of calling `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(/); ``` Передайте `character1` як перший аргумент до виклику `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1/); ``` Передайте `character2` як другий аргумент до виклику `charRange()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\{\s*const\s+inner\s*=\s*\(?\s*character\s*\)?\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\);?\s*};?\s*return\s+inner;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{\s*const\s+inner\s*=\s*(\(\s*character\s*\)|character)\s*=>\s*\{\s*return\s+idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*}\s*;?\s*return\s+inner\s*;?\s*\}\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md index ec9cf5b0faf..441a94e0aab 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1980018efaaec2b1c28b.md @@ -14,25 +14,25 @@ Use the same syntax as your `addCharacters` function to update your `elemValue` Функція `elemValue` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*\{/); ``` Your `elemValue` function should implicitly return an arrow function with a `character` parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>/); ``` Your inner arrow function should use an implicit return. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*\{/); ``` Your inner arrow function should return the result of calling `idToText()` with `character + num` as the argument. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md index 84084289f67..1494cae3067 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d19fc4705e4af65c3e688.md @@ -14,13 +14,13 @@ Your `addCharacters` function ultimately returns a range of characters. You want You should chain `.map()` to your `charRange()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(/); ``` You should not pass anything to your `.map()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md index 199fec17286..19862c6331f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1b96dd7ea4b0061458bc.md @@ -24,13 +24,13 @@ Pass a reference to your `elemValue` function as the callback to your `.map()` m You should not call your `elemValue` function. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*\)\s*\)/); ``` You should pass a reference to `elemValue` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md index e545d554480..9c3a5804505 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1cadf0d96ab0b7e12da4.md @@ -16,13 +16,13 @@ Because `elemValue` returns a function, your `addCharacters` function ultimately You should call `elemValue()` in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(/); ``` Передайте `num` до виклику `elemValue()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md index d29a24f7809..94739df900e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1d67f9261fb15a795588.md @@ -14,25 +14,25 @@ Declare a `rangeExpanded` variable and assign it the result of calling the `.rep Оголосіть змінну `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*(?:let|var|const)\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*(?:let|var|const)\s+rangeExpanded/); ``` Використайте `const`, щоб оголосити змінну `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded/); ``` You should assign the result of calling `.replace()` on `x` to your `rangeExpanded` variable. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(/); ``` Передайте `rangeRegex` як аргумент до `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md index 53596a66ae3..845abdc1867 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d1e531042dfb24da1f032.md @@ -16,13 +16,13 @@ The callback function takes a few parameters. The first is the matched string. P Передайте стрілкову функцію як другий аргумент до методу `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(.*\)|[^\s()]+)\s*=>\s*\{\s*\}\s*\)/); ``` Стрілкова функція має приймати параметр `match`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md index 7e31076efc2..f4bb202f316 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3141790b3cb337dd611a.md @@ -16,25 +16,25 @@ Give your callback function four more parameters to match those capture groups: Your callback function should have `char1` as the second parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1/); ``` Your callback function should have `num1` as the third parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1/); ``` Your callback function should have `char2` as the fourth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2/); ``` Your callback function should have `num2` as the fifth parameter. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md index 1ee0ade3358..fe51caa0493 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d382c4d70ceb3dba1e830.md @@ -14,25 +14,25 @@ Have your callback implicitly return the result of calling `rangeFromString()` w Функція зворотного виклику має використати неявне повернення. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*\{/); ``` Your callback should return the result of calling `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(/); ``` Передайте `num1` як перший аргумент до виклику `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1/); ``` Передайте `num2` як другий аргумент до виклику `rangeFromString()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md index 2b211a60d37..851010eb5dc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d386a685620b49db4be76.md @@ -14,13 +14,13 @@ Call the `.map()` method on your `rangeFromString()` call, passing a reference t You should call the `.map()` method on your `rangeFromString()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(/); ``` You should pass a reference to `addCharacters` as the callback to your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md index 56bd1104258..07f123eb8f1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38c326f3c8b54023de38.md @@ -14,13 +14,13 @@ dashedName: step-58 You should call your `addCharacters()` function in your `.map()` method. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*/); ``` Передайте `char1` як аргумент до виклику `addCharacters()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md index a83f279694f..70acb054d7f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d38f906b94cb5fe6ce7de.md @@ -20,13 +20,13 @@ Immediately invoke the function returned from your `addCharacters(char1)` call, You should chain a function call to your `addCharacters(char1)` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(/); ``` You should pass `char2` as the argument to your chained function call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md index 8fc7823f862..2ae947f8601 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3952f6af37b6a1c241c2.md @@ -18,7 +18,7 @@ Prefix your `match` parameter with an underscore. You should prefix your `match` parameter with an underscore. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md index c688978ea6c..b3d87d94a0c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d39c156fe94b7482c3ab6.md @@ -14,49 +14,49 @@ Declare a variable `cellRegex` to match cell references. It should match a lette Оголосіть змінну `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*(?:var|let|const)\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*(?:var|let|const)\s+cellRegex/); ``` Використайте `const`, щоб оголосити змінну `cellRegex`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex/); ``` You should assign a regular expression to your `cellRegex` variables. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\//); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\//); ``` Your regular expression should use a character class to match the characters from `A` to `J`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]/); ``` Your regular expression should use a character class to match the digits from `1` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]/); ``` Your regular expression should use a character class to match the digits from `0` to `9`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]/); ``` Your third character class should be optional. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?/); ``` Your regular expression should be case-insensitive and global. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md index 9acdf83edf2..9b72e01636e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3b27cd3c56b875256301.md @@ -14,43 +14,43 @@ Declare a `cellExpanded` variable and assign it the value of calling `.replace() Оголосіть змінну `cellExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*(var|let|const)\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*(var|let|const)\s+cellExpanded/); ``` Використайте `const`, щоб оголосити змінну `cellExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded/); ``` You should assign `cellExpanded` the result of calling the `.replace()` method of `rangeExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(/); ``` Передайте `cellRegex` як перший аргумент до виклику `.replace()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex/); ``` You should pass a callback function using arrow syntax as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*(?:match)?\s*\)|match)\s*=>/); ``` Функція зворотного виклику повинна мати параметр `match`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>/); ``` Функція зворотного виклику має бути порожньою. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md index bc099ffbd7f..5ba4c199ed4 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3bc75fe0c9b972da3323.md @@ -14,25 +14,25 @@ Update your callback function to return the result of calling `idToText()` with Функція зворотного виклику має використати неявне повернення. ```js -assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); +assert.notMatch(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*\{/); ``` Your callback function should call `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(/); ``` You should pass `match` to your `idToText()` call. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\s*/); ``` You should call the `.toUpperCase()` method of `match` as you pass it to `idToText()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md index 90f7d0bb3f7..f46d1f348a9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d3f718b5f8dc102cd528e.md @@ -32,19 +32,19 @@ assert.isFunction(highPrecedence); Функція `highPrecedence` повинна використовувати стрілковий синтаксис. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція `highPrecedence` повинна мати параметр `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Функція `highPrecedence` має бути порожньою. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*}/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md index c0599f46151..48374f9c51c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d404259f512c1a9e86ac1.md @@ -16,67 +16,67 @@ Each number, and the operator, should be in separate capture groups. Оголосіть змінну `regex` у функції `highPrecedence`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*(?:const|let|var)\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*(?:const|let|var)\s+regex/); ``` Використайте `const`, щоб оголосити змінну `regex`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex/); ``` Змінна `regex` має бути регулярним виразом. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\//); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//); ``` Your `regex` should use a capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[/); ``` Your first capture group should match any digit or a period. Use the special `\d` character class. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]/); ``` Your first capture group should match the character class one or more times. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `regex` should use a second capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should match a `*` or `/` operator. Use a character class in the capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)/); ``` Your `regex` should use a third capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md index b05624dd142..24d33825e50 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40c543943ec250039682.md @@ -16,31 +16,31 @@ Declare a `str2` variable and assign it the result of calling `infixEval` with ` Оголосіть змінну `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:const|let|var)\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:const|let|var)\s+str2/); ``` Використайте `const`, щоб оголосити змінну `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling your `infixEval` function. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` Передайте `str` як перший аргумент до виклику `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str/); ``` Передайте `regex` як другий аргумент до виклику `infixEval`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md index e743f2170c2..22b997b66d1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d40fe4b7b50c30c2b4cd8.md @@ -16,37 +16,37 @@ If `infixEval` does not find any matches, it will return the `str` value as-is. Your `highPrecedence` function should use the `return` keyword. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return/); ``` You should use the `return` keyword with a condition to check if `str` is equal to `str2`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)/); ``` You should use ternary syntax with your `return` statement. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?/); ``` If the ternary condition is true, you should return `str`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str/); ``` If the ternary condition is false, you should return the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(/); ``` Передайте `str2` до виклику `highPrecedence()`. ```js -assert.match(code, /const\s+highPrecedence\s*=\s*\(?\s*str\s*\)?\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\);?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); +assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\*\\\/|\\\/*)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*str\s*,\s*regex\s*\)\s*;?\s*return\s+(?:str\s*===\s*str2|str2\s*===\s*str)\s*\?\s*str\s*:\s*highPrecedence\(\s*str2\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md index 68d1611a7cd..27d8c1c1399 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d41e23b583fc3b8cc4579.md @@ -32,19 +32,19 @@ assert.isFunction(applyFunction); Функція `applyFunction` повинна використовувати стрілковий синтаксис. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*(?:str)?\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція `applyFunction` повинна мати параметр `str`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>/); ``` Функція `applyFunction` має бути порожньою. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md index 441d5f0e032..66427e1ce07 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d423fade4a9c4636acd13.md @@ -14,25 +14,25 @@ First you need to handle the higher precedence operators. Declare a `noHigh` var Оголосіть змінну `noHigh`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*(?:var|let|const)\s+noHigh\s*=/); ``` Використайте `const`, щоб оголосити змінну `noHigh`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=/); ``` You should assign `noHigh` the result of calling `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(/); ``` Передайте `str` як аргумент до виклику `highPrecedence()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md index 2a3c2a480f6..d0cdd784a09 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d42f58deb2fc52adc6611.md @@ -16,67 +16,67 @@ Declare an `infix` variable, and assign it a regular expression that matches a n Оголосіть змінну `infix`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*(?:const|let|var)\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*(?:const|let|var)\s+infix\s*=/); ``` Використайте `const`, щоб оголосити змінну `infix`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=/); ``` Змінна `infix` має бути регулярним виразом. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\//); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\//); ``` Your `infix` regex should use a capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(/); ``` Your first capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[/); ``` Your first capture group should match one or more digits or decimal points. Use the `\d` character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)/); ``` Your `infix` regex should use a second capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(/); ``` Your second capture group should use a character class. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[/); ``` Your second capture group should match either the `+` or `-` operator. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)/); ``` Your `infix` regex should use a third capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(/); ``` Your third capture group should be the same as your first capture group. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md index 2b392893e72..9c5098cbc95 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d43587d926bc5b6cb2e50.md @@ -14,31 +14,31 @@ Declare a `str2` variable, and assign it the result of calling `infixEval()` wit Оголосіть змінну `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*(?:let|var|const)\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*(?:let|var|const)\s+str2/); ``` Використайте `const`, щоб оголосити змінну `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2/); ``` You should assign `str2` the result of calling `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(/); ``` Передайте `noHigh` як перший аргумент до `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh/); ``` Передайте `infix` як другий аргумент до `infixEval()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md index 8918fd33617..84a7c18bbde 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d448479c8fdc8dcec868c.md @@ -7,7 +7,7 @@ dashedName: step-81 # --description-- -Declare a `functionCall` variable, and assign it this regular expression: `/([a-z]*)\(([0-9., ]*)\)(?!.*\()/i` +Declare a `functionCall` variable, and assign it this regular expression: `/([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i` This expression will look for function calls like `sum(1, 4)`. @@ -16,19 +16,19 @@ This expression will look for function calls like `sum(1, 4)`. Оголосіть змінну `functionCall`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*(?:const|let|var)\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*(?:const|let|var)\s+functionCall\s*=/); ``` Використайте `const`, щоб оголосити змінну `functionCall`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=/); ``` You should assign `functionCall` the provided regular expression. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*\,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md index 1a601c9f9c8..a18dfdb1f45 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d44da986f2bc9b72f5fe2.md @@ -7,62 +7,62 @@ dashedName: step-82 # --description-- -Declare a `toNumberList` function which takes an `args` parameter, and returns the result of splitting the `args` by commas, and mapping the resulting array to `parseFloat`. +Declare a `toNumberList` function that takes an `args` parameter and implicitly returns the result of splitting the `args` by commas. Then chain a `map` method to your `split` method and pass in `parseFloat` as the argument to the `map` method. # --hints-- Оголосіть змінну `toNumberList`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*(?:const|let|var)\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*(?:const|let|var)\s+toNumberList\s*=/); ``` Використайте `const`, щоб оголосити змінну `toNumberList`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=/); ``` Змінна `toNumberList` має бути стрілковою функцією. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*(?:args)?\s*\)|args)\s*=>/); ``` Функція `toNumberList` повинна мати параметр `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>/); ``` Функція `toNumberList` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*\{/); ``` Функція `toNumberList` має повернути результат виклику методу `.split()` на `args`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(\(\s*args\s*\)|args)\s*=>\s*args\.split\(/); ``` You should split `args` on the `,` character. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)/); ``` You should chain the `.map()` method to the `.split()` method. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(/); ``` You should pass a reference to `parseFloat` as the callback to `.map()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?/); ``` @@ -143,7 +143,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; } --fcc-editable-region-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md index bedbfddc83c..fe5a83d3943 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d451c2e44afca71b67818.md @@ -14,37 +14,37 @@ Declare an `apply` function that takes a `fn` and `args` parameter. Оголосіть змінну `apply`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*(?:var|let|const)\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*(?:var|let|const)\s+apply\s*=/); ``` Використайте `const`, щоб оголосити змінну `apply`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=/); ``` Your `apply` variable should be assigned an arrow function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(/); ``` Функція `apply` повинна мати `fn` як перший параметр. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn/); ``` Функція `apply` повинна мати `args` як другий параметр. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)/); ``` Функція `apply` має бути порожньою. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{\s*\}/); ``` # --seed-- @@ -124,7 +124,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md index eae1d3ec443..9fab0c946c9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4554721d43cb19a68bc4.md @@ -16,25 +16,25 @@ Remember that `fn` might not be lowercase, so you'll need to convert it to a low Функція `apply` має використати неявне повернення. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Функція `apply` має отримати доступ до об’єкта `spreadsheetFunctions`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions/); ``` Функція `apply` має отримати доступ до властивості об’єкта `spreadsheetFunctions`, що відповідає значенню `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn/); ``` Your `apply` function should call the `.toLowerCase()` method on `fn` in the property access. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]/); ``` @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => {} } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md index 0918bc69bad..f68a0af759a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45b739da5ecbf830c108.md @@ -14,19 +14,19 @@ Your `apply` function is returning the spreadsheet function, but not actually ap Your `apply` function should call the `spreadsheetFunctions[fn.toLowerCase()]` function. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(/); ``` Передайте виклик `toNumberList()` до виклику `spreadsheetFunctions[fn.toLowerCase()]`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(/); ``` Передайте `args` до виклику `toNumberList()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)/); ``` # --seed-- @@ -106,7 +106,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()]; } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md index 46a9c8d1c6c..761277f2a36 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d45ee725632cca2555146.md @@ -14,19 +14,19 @@ Now your `applyFunction` needs to return a result. Return the result of calling Функція `applyFunction` має повернути результат виклику методу `.replace()` на `str2`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(/); ``` Передайте `functionCall` як перший аргумент до виклику `.replace()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall/); ``` You should pass an empty arrow function as the second argument to your `.replace()` call. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*\)\s*=>\s*\{\s*\}/); ``` @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md index 2193c1e79a5..85f9d69fea1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4626420eeecd51f241c2.md @@ -16,43 +16,43 @@ Remember to make `fn` lower case. Функція зворотного виклику повинна мати `match` як перший параметр. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match/); ``` Функція зворотного виклику повинна мати `fn` як другий параметр. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn/); ``` Функція зворотного виклику повинна мати `args` як третій параметр. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>/); ``` Функція зворотного виклику має використати неявне повернення. ```js -assert.notMatch(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); +assert.notMatch(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*\{/); ``` Функція зворотного виклику має повернути результат виклику методу `.hasOwnProperty()` на об’єкті `spreadsheetFunctions`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(/); ``` Передайте `fn` до методу `.hasOwnProperty()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn/); ``` You should call the `.toLowerCase()` method on `fn`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)/); ``` # --seed-- @@ -132,7 +132,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, () => {}) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md index 42522e77368..bb98267e434 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d467c6994f4ce0dc416a4.md @@ -14,31 +14,31 @@ Use the ternary operator to turn your `.hasOwnProperty()` call into the conditio Your callback function should use ternary syntax. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?/); ``` If the ternary condition is true, your callback function should return the result of calling `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\s*\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\s*\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(/); ``` Передайте `fn` як перший аргумент до виклику `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn/); ``` Передайте `args` як другий аргумент до виклику `apply()`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)/); ``` If the ternary is false, you should return `match`. ```js -assert.match(code, /const\s+applyFunction\s*=\s*\(?\s*str\s*\)?\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\);?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\);?\s*const\s+functionCall\s*=\s*\/\(\[a-z\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i;?\s*const\s+toNumberList\s*=\s*\(?\s*args\s*\)?\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\);?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\);?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); +assert.match(code, /const\s+applyFunction\s*=\s*(?:\(\s*str\s*\)|str)\s*=>\s*\{\s*const\s+noHigh\s*=\s*highPrecedence\(\s*str\s*\)\s*;?\s*const\s+infix\s*=\s*\/\(\[(?:\\d\.|\.\\d)\]\+\)\(\[(?:\+-|-\+)\]\)\(\[(?:\\d\.|\.\\d)\]\+\)\/\s*;?\s*const\s+str2\s*=\s*infixEval\(\s*noHigh\s*,\s*infix\s*\)\s*;?\s*const\s+functionCall\s*=\s*\/\(\[a-z0-9\]\*\)\\\(\(\[0-9\., \]\*\)\\\)\(\?!\.\*\\\(\)\/i\s*;?\s*const\s+toNumberList\s*=\s*(?:\(\s*args\s*\)|args)\s*=>\s*args\.split\(\s*('|"|`),\1\s*\)\.map\(\s*parseFloat\s*\)\s*;?\s*const\s+apply\s*=\s*\(\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\s*\[\s*fn\.toLowerCase\(\s*\)\s*\]\s*\(\s*toNumberList\(\s*args\s*\)\s*\)\s*;?\s*return\s+str2\.replace\(\s*functionCall\s*,\s*\(\s*match\s*,\s*fn\s*,\s*args\s*\)\s*=>\s*spreadsheetFunctions\.hasOwnProperty\(\s*fn\.toLowerCase\(\s*\)\s*\)\s*\?\s*apply\(\s*fn\s*,\s*args\s*\)\s*:\s*match/); ``` # --seed-- @@ -118,7 +118,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md index 69fc9cee4b9..14f8fccf872 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d46c03e7d02cecb30f021.md @@ -14,25 +14,25 @@ Now you can start applying your function parser to your `evalFormula` logic. Dec Оголосіть змінну `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*/); ``` Використайте `const`, щоб оголосити змінну `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*const\s+functionExpanded\s*=\s*/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*const\s+functionExpanded\s*=\s*/); ``` You should assign the `functionExpanded` variable the result of calling your `applyFunction` function. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(/); ``` Передайте `cellExpanded` до виклику `applyFunction`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?/); ``` # --seed-- @@ -111,7 +111,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md index 0bdc39ba67f..a39c8a3a081 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4717a689e1cfa232e357.md @@ -16,43 +16,43 @@ Use a ternary to check if `functionExpanded` is equal to the original string `x` Your `evalFormula` function should use the `return` keyword. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return/); ``` Your `return` statement should check if `functionExpanded` is equal to `x`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)/); ``` Your `return` statement should use a ternary operator. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?/); ``` If the ternary condition is true, your `evalFormula()` should return `functionExpanded`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded/); ``` If the ternary condition is false, your `evalFormula()` should return the result of calling `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(/); ``` Передайте `functionExpanded` як перший аргумент до виклику `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded/); ``` Передайте `cells` як другий аргумент до виклику `evalFormula()`. ```js -assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*\(?\s*id\s*\)?\s*=>\s*cells\.find\(\s*\(?\s*cell\s*\)?\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig);?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\);?\s*const\s+elemValue\s*=\s*\(?\s*num\s*\)?\s*=>\s*\(?\s*character\s*\)?\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\);?\s*const\s+addCharacters\s*=\s*\(?\s*character1\s*\)?\s*=>\s*\(?\s*character2\s*\)?\s*=>\s*\(?\s*num\s*\)?\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\);?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\);?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig);?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*\(?\s*match\s*\)?\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\);?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\);?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\);?/); +assert.match(code, /const\s+evalFormula\s*=\s*\(\s*x\s*,\s*cells\s*\)\s*=>\s*{\s*const\s+idToText\s*=\s*(\(\s*id\s*\)|id)\s*=>\s*cells\.find\(\s*(\(\s*cell\s*\)|cell)\s*=>\s*(?:cell\.id\s*===\s*id|id\s*===\s*cell\.id)\s*\)\.value\s*;?\s*const\s+rangeRegex\s*=\s*\/\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\):\(\[A-J\]\)\(\[1-9\]\[0-9\]\?\)\/(gi|ig)\s*;?\s*const\s+rangeFromString\s*=\s*\(\s*num1\s*,\s*num2\s*\)\s*=>\s*range\(\s*parseInt\(\s*num1\s*\)\s*,\s*parseInt\(\s*num2\s*\)\s*\)\s*;?\s*const\s+elemValue\s*=\s*(\(\s*num\s*\)|num)\s*=>\s*(\(\s*character\s*\)|character)\s*=>\s*idToText\(\s*character\s*\+\s*num\s*\)\s*;?\s*const\s+addCharacters\s*=\s*(\(\s*character1\s*\)|character1)\s*=>\s*(\(\s*character2\s*\)|character2)\s*=>\s*(\(\s*num\s*\)|num)\s*=>\s*charRange\(\s*character1\s*,\s*character2\s*\)\.map\(\s*elemValue\(\s*num\s*\)\s*\)\s*;?\s*const\s+rangeExpanded\s*=\s*x\.replace\(\s*rangeRegex\s*,\s*\(\s*_match\s*,\s*char1\s*,\s*num1\s*,\s*char2\s*,\s*num2\s*\)\s*=>\s*rangeFromString\(\s*num1\s*,\s*num2\s*\)\.map\(\s*addCharacters\s*\(\s*char1\s*\)\(\s*char2\s*\)\s*\)\s*\)\s*;?\s*const\s+cellRegex\s*=\s*\/\[A-J\]\[1-9\]\[0-9\]\?\/(gi|ig)\s*;?\s*const\s+cellExpanded\s*=\s*rangeExpanded\.replace\(\s*cellRegex\s*,\s*(\(\s*match\s*\)|match)\s*=>\s*idToText\(\s*match\.toUpperCase\(\s*\)\s*\)\s*\)\s*;?\s*(?:const|let|var)\s+functionExpanded\s*=\s*applyFunction\(\s*cellExpanded\s*\)\s*;?\s*return\s+(?:functionExpanded\s*===\s*x|x\s*===\s*functionExpanded)\s*\?\s*functionExpanded\s*:\s*evalFormula\(\s*functionExpanded\s*,\s*cells\s*\)\s*;?/); ``` # --seed-- @@ -131,7 +131,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md index f6b92672e2d..3653fac6892 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4769ba65f1d05ef6b634.md @@ -16,19 +16,19 @@ Inside your `if` statement, set the `value` of the `element` to be the result of You should update the `value` property of `element` in your `if` block. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value/); ``` You should assign the `value` property the result of calling your `evalFormula()` function. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(/); ``` You should not pass any arguments to your `evalFormula()` call. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*\)/); ``` # --seed-- @@ -107,7 +107,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md index d284621b758..c6c330448e2 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d47c8f58107d10f1e5106.md @@ -14,19 +14,19 @@ The first argument for your `evalFormula` call needs to be the contents of the c Передайте `value` як перший аргумент до виклику `evalFormula()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value/); ``` You should call the `.slice()` method on the `value` argument. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(/); ``` Передайте число `1` як аргумент до виклику `.slice()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.(?:slice|substring)\(\s*1\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md index 924b5db200b..7a334eafd2b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4813c17b37d1e261a566.md @@ -14,19 +14,19 @@ You can quickly get all cells from your page by getting the `#container` element For the second parameter of your `evalFormula()` call, you should call the `.getElementById()` method of the `document` object. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(/); ``` Передайте `container` як аргумент до виклику `.getElementById()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)/); ``` Отримайте доступ до властивості `children` результату виклику `.getElementById()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*;?/); ``` # --seed-- @@ -105,7 +105,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md index 58221a81fae..a72fad04c27 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d486aec20f7d2a581cc36.md @@ -14,7 +14,7 @@ Unfortunately, that `children` property is returning a collection of elements, w You should wrap your `document.getElementById('container').children` in `Array.from()`. ```js -assert.match(code, /const\s+update\s*=\s*\(?\s*event\s*\)?\s*=>\s*\{\s*const\s+element\s*=\s*event\.target;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\);?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\);?/); +assert.match(code, /const\s+update\s*=\s*(?:\(\s*event\s*\)|event)\s*=>\s*\{\s*const\s+element\s*=\s*event\.target\s*;?\s*const\s+value\s*=\s*element\.value\.replace\(\s*\/\\s\/g\s*,\s*('|"|`)\1\s*\)\s*;?\s*if\s*\(\s*(!value\.includes\(\s*element\.id\s*\)\s*&&\s*(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\3|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\4|value\.startsWith\(\s*('|"|`)=\5\s*\))|(?:value\s*\[\s*0\s*\]\s*===\s*('|"|`)=\6|value\.charAt\(\s*0\s*\)\s*===\s*('|"|`)=\7|value\.startsWith\(\s*('|"|`)=\8\s*\))\s*\|\|\s*!value\.includes\(\s*element\.id\s*\))\s*\)\s*\{\s*element\.value\s*=\s*evalFormula\(\s*value\.slice\(\s*1\s*\)\s*,\s*Array\.from\(\s*document\.getElementById\(\s*('|"|`)container\9\s*\)\.children\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -93,7 +93,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md index a1365d2b9ca..e3a85cfaace 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d48b936802fd34c3f05af.md @@ -28,25 +28,25 @@ assert.isFunction(spreadsheetFunctions.even); Функція `even` має приймати параметр `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>/) ``` Функція `even` має використати неявне повернення. ```js -assert.notMatch(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*\{/) +assert.notMatch(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*\{/) ``` Функція `even` має повернути результат виклику методу `.filter()` на `nums`. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter/) ``` You should pass a reference to your `isEven()` function as the callback for the `.filter()` method. ```js -assert.match(code, /even\s*:\s*\(?\s*nums\s*\)?\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) +assert.match(code, /even\s*:\s*(\(\s*nums\s*\)|nums)\s*=>\s*nums\s*\.\s*filter\s*\(\s*isEven\s*\)/) ``` Your `even` function should return an array of even numbers. @@ -134,7 +134,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md index 6bb8aab679d..132d306ea58 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d498c8ebc31d3f753b22e.md @@ -127,7 +127,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md index 87b47f2d570..4996b696517 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d49bfff9079d4b38df115.md @@ -135,7 +135,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md index 69e785bff45..28b6ff5ea4e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a07a8fb14d55cd70e09.md @@ -128,7 +128,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md index 1037691c2eb..a64f622ca92 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a5b32a1cad6165df286.md @@ -123,7 +123,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md index e76830f05c4..e43d9e1d409 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4a8dbc04c6d6bb0001f8.md @@ -116,7 +116,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md index baf32d116db..a9211ff004b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4ab9b3b4c5d74fdd2154.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md index 06bc777ae3a..44cd60f0485 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/646d4b3d80ea98d824c8a4f9.md @@ -120,7 +120,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); @@ -259,7 +259,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md index 276d8019caa..db4e6525c61 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-functional-programming-by-building-a-spreadsheet/6491d38f5b09a021c4b5d5fe.md @@ -129,7 +129,7 @@ const applyFunction = str => { const noHigh = highPrecedence(str); const infix = /([\d.]+)([+-])([\d.]+)/; const str2 = infixEval(noHigh, infix); - const functionCall = /([a-z]*)\(([0-9., ]*)\)(?!.*\()/i; + const functionCall = /([a-z0-9]*)\(([0-9., ]*)\)(?!.*\()/i; const toNumberList = args => args.split(",").map(parseFloat); const apply = (fn, args) => spreadsheetFunctions[fn.toLowerCase()](toNumberList(args)); return str2.replace(functionCall, (match, fn, args) => spreadsheetFunctions.hasOwnProperty(fn.toLowerCase()) ? apply(fn, args) : match); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md index 56c0bf5ed8a..1a62fade623 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/6579fc66adaabbca6ceddb1f.md @@ -24,7 +24,7 @@ assert.match(code, /const\s+listOfAllDice\s*/); You should assign the `document.querySelectorAll()` method to the `listOfAllDice` variable. ```js -assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\);?/); +assert.match(code, /const\s+listOfAllDice\s*=\s*document\.querySelectorAll\s*\(.*\)\s*;?/); ``` You should target all elements with the `class` of `die` inside the `querySelectorAll` method. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md index 679eb6a2cfd..8f972f15926 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657a018ddd0006ce5bc29fa4.md @@ -42,7 +42,7 @@ assert.match(code, /const\s+scoreSpans\s*/); You should assign the `document.querySelectorAll()` method to the `scoreSpans` variable. ```js -assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\);?/); +assert.match(code, /const\s+scoreSpans\s*=\s*document\.querySelectorAll\(.*\)\s*;?/); ``` You should target all of the `span` elements inside the `#score-options` `div` element. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md index 1590cf858dd..782f32e7415 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ca764afcc5221ee01f1a9.md @@ -28,7 +28,7 @@ assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*('|"|`)\s*click\s*\1\s* You should have an empty arrow function for the second argument for the `addEventListener()` method. ```js -assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\);/); +assert.match(code, /rollDiceBtn\.addEventListener\s*\(\s*("|'|`)\s*click\s*\1\s*,\s*\(\s*\)\s*=>\s*{\s*[\s\S]*\s*}\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md index a07c77447cb..a4409de7b8c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657caf204c0d672a35411c31.md @@ -22,13 +22,13 @@ assert.isFunction(updateRadioOption); You should use arrow syntax for the `updateRadioOption` function. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(.*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` Your `updateRadioOption` function should take `optionNode` and `score` as parameters. ```js -assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*};?/) +assert.match(code, /const\s+updateRadioOption\s*=\s*\(\s*optionNode\s*,\s*score\s*\)\s*=>\s*{\s*[\s\S]*}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md index 48d5fa98c62..2268945c23b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657ccb8022b59543d2e391b7.md @@ -14,7 +14,7 @@ To display the current score, update the text content for the `span` element nex You should set the `textContent` property for `scoreSpans[optionNode]` to the following template literal: `, score = ${score}`. ```js -assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`;?/); +assert.match(code, /scoreSpans\s*\[\s*optionNode\s*\]\s*\.textContent\s*=\s*`, score = \${score}`\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md index 3b3795fc72f..e9bca85c4ba 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cd762ea9e6a47c459ee8b.md @@ -16,13 +16,13 @@ Roll the dice again and you should see that the first radio button is enabled an You should call the `updateRadioOption` inside the `else` clause of the `rollDiceBtn` callback function. ```js -assert.match(code, /updateRadioOption\(.*\);?/); +assert.match(code, /updateRadioOption\(.*\)\s*;?/); ``` You should have the arguments of `0` and `10` for the `updateRadioOption` function. ```js -assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.match(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md index 62941c2dec9..79d26879593 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf2b586b3495a69394d7c.md @@ -14,7 +14,7 @@ Now that you have verified the `updateRadioOption` function works, remove the fu You should remove the `updateRadioOption` function call from your `else` clause. ```js -assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\);?/); +assert.notMatch(code, /updateRadioOption\(\s*0\s*,\s*10\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md index 68928b71ec2..c4a10683611 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cf677438e705eab9fd1f9.md @@ -22,13 +22,13 @@ assert.isFunction(getHighestDuplicates); Your `getHighestDuplicates` should use the arrow syntax. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?.*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{\s*}\s*;?/); ``` Your `getHighestDuplicates` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+getHighestDuplicates\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*}\s*;?/); +assert.match(code, /const\s+getHighestDuplicates\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*}\s*;?/); ``` # --seed-- @@ -286,8 +286,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md index 38b3ce49bbc..c1127001ffc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657cfad68610a4654bb171f4.md @@ -22,7 +22,7 @@ assert.match(getHighestDuplicates.toString(), /counts\s*=/); Your `counts` variable should be an empty object. ```js -assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\};?/); +assert.match(getHighestDuplicates.toString(), /counts\s*=\s*\{\s*\}\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md index 53f8d9f5563..3d1df2f042c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d301f80931609b9a5d110.md @@ -22,7 +22,7 @@ assert.match(code, /scoreInputs\.forEach/); You should apply a callback function to the `forEach` method with a parameter called `input`. ```js -assert.match(code, /scoreInputs\.forEach\(\s*\(\s*input\s*\)?\s*=>/); +assert.match(code, /scoreInputs\.forEach\(\s*(\(\s*input\s*\)|input)\s*=>/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md index 5b435594a01..a694832fe69 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d374ef92a36145abdd215.md @@ -24,13 +24,13 @@ assert.match(code, /scoreSpans\.forEach/); You should apply a callback function to the `forEach` method with parameter called `span`. ```js -assert.match(code, /scoreSpans\.forEach\(\s*\(?\s*span\s*\)?\s*=>\s*{[\s\S]*}\s*\)/); +assert.match(code, /scoreSpans\.forEach\(\s*(\(\s*span\s*\)|span)\s*=>\s*{[\s\S]*}\s*\)/); ``` You should set the `textContent` property of the `span` element to an empty string. ```js -assert.match(code, /span\.textContent\s*=\s*('|")\1;?/); +assert.match(code, /span\.textContent\s*=\s*('|")\1\s*;?/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md index cadfac61a12..8bc9b03e53b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657d397542d1a2162407ac39.md @@ -16,7 +16,7 @@ Now, try rolling the dice again and you should see that the previous score `inpu You should call the `resetRadioOption` function inside the `rollDiceBtn` callback function. ```js -assert.match(code, /resetRadioOption\(\s*\);?/); +assert.match(code, /resetRadioOption\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md index a4c94b5ac24..cc98da818cd 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e09d4802a136e868a7f5e.md @@ -16,7 +16,7 @@ Now you should be able to play the game for six rounds, end the game and have it You should call your `resetGame` function inside the `keepScoreBtn` event listener. ```js -assert.match(code, /resetGame\s*\(\s*\);?/); +assert.match(code, /resetGame\s*\(\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md index 55245e6843f..b6e12fbde86 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e0c2c6a9d37705146f34d.md @@ -26,19 +26,19 @@ assert.isFunction(detectFullHouse); You should use arrow syntax for your `detectFullHouse` function. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*.*\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>\s*{/); ``` Your `detectFullHouse` function should have a parameter called `arr`. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{/); ``` You should have a `const` variable called `counts` and assign an empty object to it. ```js -assert.match(code, /const\s+detectFullHouse\s*=\s*\(?\s*arr\s*\)?\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); +assert.match(code, /const\s+detectFullHouse\s*=\s*(\(\s*arr\s*\)|arr)\s*=>\s*{\s*const\s+counts\s*=\s*{\s*}\s*;?\s*}/); ``` # --seed-- @@ -296,8 +296,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md index 2a4526a6e08..8323a6e0a4f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e21575e71e2822f3b0abd.md @@ -16,7 +16,7 @@ Try playing a few rounds of the game to see if you can land on a `Full house`. You should call the `detectFullHouse` and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /detectFullHouse\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md index a3c43d28af6..e30810b8f57 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e230500602983e01fff6e.md @@ -24,13 +24,13 @@ assert.isFunction(checkForStraights); Your `checkForStraights` function should use arrow syntax. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*(?:arr)?\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `checkForStraights` function should have a `arr` parameter. ```js -assert.match(code, /const\s+checkForStraights\s*=\s*\(?\s*arr\s*\)?\s*=>/); +assert.match(code, /const\s+checkForStraights\s*=\s*(\(\s*arr\s*\)|arr)\s*=>/); ``` # --seed-- @@ -288,8 +288,8 @@ let diceValuesArr = []; let isModalShowing = false; let score = 0; let totalScore = 0; -let round = 1; -let rolls = 0; +let round = 1; +let rolls = 0; const rollDice = () => { diceValuesArr = []; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md index 5b75f783215..d99d42d3296 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e253cf2c01685ed84c1ee.md @@ -30,13 +30,13 @@ assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr.*/); You should apply the `sort` array method on the `arr` parameter. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\);?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*arr\.sort\(.*\)\s*;?/); ``` Your callback function should use `a` and `b` for the parameters and implicitly return `a - b`. ```js -assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\));?/); +assert.match(code, /const\s+sortedNumbersArr\s*=\s*(?:arr\.sort\(\s*\(\s*a\s*,\s*b\s*\)\s*=>\s*a\s*-\s*b\s*\))\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md index 696f907270d..28e9501fa28 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e2bac662a3c8f5801d550.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+uniqueNumbersStr\s*=?\s*;?/); You should the use the `join("")` method on the `uniqueNumbersArr`. ```js -assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\);?/); +assert.match(code, /const\s+uniqueNumbersStr\s*=\s*uniqueNumbersArr\.join\(\s*('|")\1\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md index ae41ee8a363..d3cd8e00717 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-algorithmic-thinking-by-building-a-dice-game/657e390964da9f9bff8f3625.md @@ -16,7 +16,7 @@ And with that last change, you have completed your dice game! You should call the `checkForStraights` function and pass in the `diceValuesArr` variable for the argument. ```js -assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\);?/); +assert.match(code, /checkForStraights\s*\(\s*diceValuesArr\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md index bb4de4ac701..f35ac4d4681 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482b4fef5fd6bcdfddad730.md @@ -1,8 +1,8 @@ --- id: 6482b4fef5fd6bcdfddad730 -title: Крок 10 +title: Step 12 challengeType: 0 -dashedName: step-10 +dashedName: step-12 --- # --description-- @@ -182,6 +182,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- --fcc-editable-region-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md index 6c98d16f185..f290586fdd9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6482bc5d699f0acfc52bdc41.md @@ -1,18 +1,16 @@ --- id: 6482bc5d699f0acfc52bdc41 -title: Крок 11 +title: Step 13 challengeType: 0 -dashedName: step-11 +dashedName: step-13 --- # --description-- Inside your `Player` class, you will need to define the player's position, velocity, width, and height values. All of these values will be defined inside the constructor method. - Create an empty constructor inside your `Player` class. - # --hints-- You should add a `constructor` method to the `Player` class. @@ -176,6 +174,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md index efab6ff245d..12cfc0ac73b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861a8856e1eaf9e349570e.md @@ -1,8 +1,8 @@ --- id: 64861a8856e1eaf9e349570e -title: Крок 12 +title: Step 14 challengeType: 0 -dashedName: step-12 +dashedName: step-14 --- # --description-- @@ -169,6 +169,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md index 845cebf204a..12fe1c37d51 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64861c02ff1ef4fa62a9e132.md @@ -1,60 +1,53 @@ --- id: 64861c02ff1ef4fa62a9e132 -title: Крок 13 +title: Step 15 challengeType: 0 -dashedName: step-13 +dashedName: step-15 --- # --description-- -Inside your `position` object, add a new key called `x` with a value of `10`. After that, add another key called `y` with a value of `400`. +Inside your `position` object, add a new key called `x` with a value of `proportionalSize(10)`. After that, add another key called `y` with a value of `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure that the player's position is always proportional to the screen size. This is important because you want the player to be able to move around the screen regardless of the screen size. # --hints-- -You should add a new key called `x` with a value of 10. +You should add a new key called `x` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('x') && - obj.x !== undefined && - typeof obj.x === 'number' && - obj.x === 10 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'x'); +``` + +You should set the value of `x` to `proportionalSize(10)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'x', proportionalSize(10)); ``` -You should add a key called `y` with a value of 400. - +You should add a key called `y` to your `position` object. ```js assert.match(code, /this\.position/); const player = new Player(); -assert( - (function (obj) { - if ( - obj.hasOwnProperty('y') && - obj.y !== undefined && - typeof obj.y === 'number' && - obj.y === 400 - ) { - return true; - } else { - return false; - } - })(player.position) -); +assert.property(player.position, 'y'); +``` + +You should set the value of `y` to `proportionalSize(400)`. + +```js +assert.match(code, /this\.position/); +const player = new Player(); + +assert.propertyVal(player.position, 'y', proportionalSize(400)); ``` # --seed-- @@ -206,6 +199,10 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md index a3f28600e18..b951a3e6536 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486212f80701cfb18052eae.md @@ -1,8 +1,8 @@ --- id: 6486212f80701cfb18052eae -title: Крок 14 +title: Step 16 challengeType: 0 -dashedName: step-14 +dashedName: step-16 --- # --description-- @@ -11,6 +11,8 @@ Below your `position` object, use the `this` keyword to set the `velocity` prope Inside that new `velocity` object, create a key called `x` with a value of `0` and a new key called `y` with a value of `0`. +The `velocity` property will be used to store the player's speed in the `x` and `y` directions. + # --hints-- You should use the `this` keyword to set the `velocity` property of your class to an object. @@ -216,13 +218,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md index 26aa295b32c..4c8d4e75a7d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64862530b093dbfbea58f43d.md @@ -1,32 +1,34 @@ --- id: 64862530b093dbfbea58f43d -title: Крок 15 +title: Step 17 challengeType: 0 -dashedName: step-15 +dashedName: step-17 --- # --description-- -Below your `velocity` object, use the `this` keyword to set the `width` property to the number `40`. +Below your `velocity` object, use the `this` keyword to set the `width` property to `proportionalSize(40)`. -Below your `width` property, use the `this` keyword to set the `height` property to the number `40`. +Below your `width` property, use the `this` keyword to set the `height` property to `proportionalSize(40)`. + +You are using the `proportionalSize()` function here to set the `width` and `height` properties of your class to be proportional to the height of the screen. # --hints-- -You should use the `this` keyword to set the `width` property of your class to `40`. +You should use the `this` keyword to set the `width` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.width/); const player = new Player(); -assert.equal(player.width, 40); +assert.equal(player.width, proportionalSize(40)); ``` -You should use the `this` keyword to set the `height` property of your class to `40`. +You should use the `this` keyword to set the `height` property of your class to `proportionalSize(40)`. ```js assert.match(code, /this\.height/); const player = new Player(); -assert.equal(player.height, 40); +assert.equal(player.height, proportionalSize(40)); ``` # --seed-- @@ -178,13 +180,17 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + --fcc-editable-region-- class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md index 2ebc443ab8e..9623313563f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6486282ca3a469fca6ebed27.md @@ -1,8 +1,8 @@ --- id: 6486282ca3a469fca6ebed27 -title: Крок 16 +title: Step 18 challengeType: 0 -dashedName: step-16 +dashedName: step-18 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md index 603abfe2643..1e3ad2606b7 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a6b393a10a4357087b3f7.md @@ -1,8 +1,8 @@ --- id: 649a6b393a10a4357087b3f7 -title: Крок 17 +title: Step 19 challengeType: 0 -dashedName: step-17 +dashedName: step-19 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md index 830a025c82f..6d5f984a543 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a75a844f2ea3a0060d807.md @@ -1,8 +1,8 @@ --- id: 649a75a844f2ea3a0060d807 -title: Крок 18 +title: Step 20 challengeType: 0 -dashedName: step-18 +dashedName: step-20 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } --fcc-editable-region-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md index cbff4f645d5..09a6c46c14b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a80aa4405823b3f81a47f.md @@ -1,8 +1,8 @@ --- id: 649a80aa4405823b3f81a47f -title: Крок 19 +title: Step 21 challengeType: 0 -dashedName: step-19 +dashedName: step-21 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md index cda40642d2b..33379e677b3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a845dccffd93c0d41ad4b.md @@ -1,8 +1,8 @@ --- id: 649a845dccffd93c0d41ad4b -title: Крок 20 +title: Step 22 challengeType: 0 -dashedName: step-20 +dashedName: step-22 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md index 86a0f1ecf1e..83a323889a9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/649a88458b4e343fbdffbbc0.md @@ -1,8 +1,8 @@ --- id: 649a88458b4e343fbdffbbc0 -title: Крок 21 +title: Step 23 challengeType: 0 -dashedName: step-21 +dashedName: step-23 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md index b19898efe43..cac4131d84c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d39230e33585f3dd0dae.md @@ -1,8 +1,8 @@ --- id: 64a1d39230e33585f3dd0dae -title: Крок 22 +title: Step 24 challengeType: 0 -dashedName: step-22 +dashedName: step-24 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md index 444969c74d2..5544f4b3398 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1d86b1294b2869cef1c18.md @@ -1,8 +1,8 @@ --- id: 64a1d86b1294b2869cef1c18 -title: Крок 23 +title: Step 25 challengeType: 0 -dashedName: step-23 +dashedName: step-25 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md index 17afa38b5b1..5e3a93aee81 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e1b74d2e4e019acb70b8.md @@ -1,17 +1,17 @@ --- id: 64a1e1b74d2e4e019acb70b8 -title: Крок 24 +title: Step 26 challengeType: 0 -dashedName: step-24 +dashedName: step-26 --- # --description-- -In the `if` statement, add another `if` statement to check if the player's `y` position is less than 0. +In the `if` statement, add another `if` statement to check if the player's `y` position is less than `0`. # --hints-- -Your condition for the `if` statement should check if the player's `y` position is less than 0. +Your condition for the `if` statement should check if the player's `y` position is less than `0`. ```js const player = new Player(); @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md index d6d3d8463a2..1e5ffcb96ab 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1e54abad976028a8938f1.md @@ -1,8 +1,8 @@ --- id: 64a1e54abad976028a8938f1 -title: Крок 25 +title: Step 27 challengeType: 0 -dashedName: step-25 +dashedName: step-27 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md index 7e0ae1bcfac..d2bd27ec59e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a1fdbf48e08b06e8b05870.md @@ -1,8 +1,8 @@ --- id: 64a1fdbf48e08b06e8b05870 -title: Крок 26 +title: Step 28 challengeType: 0 -dashedName: step-26 +dashedName: step-28 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md index 47a2c603a1b..ff528b02d09 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2cadabc8538152c49a7eb.md @@ -1,8 +1,8 @@ --- id: 64a2cadabc8538152c49a7eb -title: Крок 27 +title: Step 29 challengeType: 0 -dashedName: step-27 +dashedName: step-29 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md index a1135957cb6..1b61fb95bb0 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2ceb58fe10e15e0dc223f.md @@ -1,8 +1,8 @@ --- id: 64a2ceb58fe10e15e0dc223f -title: Крок 28 +title: Step 30 challengeType: 0 -dashedName: step-28 +dashedName: step-30 --- # --description-- @@ -30,7 +30,7 @@ You should add an `else` clause that assigns 0 to `this.velocity.y`. ```js const player = new Player(); -assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0;?/); +assert.match(player.update.toString(), /this\.velocity\.y\s*=\s*0\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md index 13907b10b43..a09f0d04543 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d19c5029ba166cb912e5.md @@ -1,8 +1,8 @@ --- id: 64a2d19c5029ba166cb912e5 -title: Крок 29 +title: Step 31 challengeType: 0 -dashedName: step-29 +dashedName: step-31 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md index c2251c478a1..a9c705c8ffc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d5f23518e71727cac0db.md @@ -1,8 +1,8 @@ --- id: 64a2d5f23518e71727cac0db -title: Крок 30 +title: Step 32 challengeType: 0 -dashedName: step-30 +dashedName: step-32 --- # --description-- @@ -16,7 +16,7 @@ Your `if` statement should contain an assignment of the width to the player's `x ```js const player = new Player(); -assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width;?/); +assert.match(player.update.toString(), /this\.position\.x\s*=\s*this\.width\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md index ee4edec8f77..ea938883a6d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64a2d86799a58517c29f79a5.md @@ -1,8 +1,8 @@ --- id: 64a2d86799a58517c29f79a5 -title: Крок 31 +title: Step 35 challengeType: 0 -dashedName: step-31 +dashedName: step-35 --- # --description-- @@ -179,18 +179,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -215,6 +219,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md index 4ec0e088134..7ad19036d5c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf2aff7f1fc7a550f40cb.md @@ -1,8 +1,8 @@ --- id: 64aaf2aff7f1fc7a550f40cb -title: Крок 32 +title: Step 36 challengeType: 0 -dashedName: step-32 +dashedName: step-36 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md index 84884f63f28..b259524d2d5 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aaf83d46b16a7b20a27051.md @@ -1,8 +1,8 @@ --- id: 64aaf83d46b16a7b20a27051 -title: Крок 33 +title: Step 37 challengeType: 0 -dashedName: step-33 +dashedName: step-37 --- # --description-- @@ -200,18 +200,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -236,6 +240,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md index 733941f4fd0..fc3853e0f9f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab0134716d0a7c8889f167.md @@ -1,8 +1,8 @@ --- id: 64ab0134716d0a7c8889f167 -title: Крок 34 +title: Step 38 challengeType: 0 -dashedName: step-34 +dashedName: step-38 --- # --description-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md index 04046d263c4..48876b1a321 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab06a9cc033b7d4a8bad2a.md @@ -1,8 +1,8 @@ --- id: 64ab06a9cc033b7d4a8bad2a -title: Крок 35 +title: Step 39 challengeType: 0 -dashedName: step-35 +dashedName: step-39 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md index df6624717b8..9542bb0ae4b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab143edad72b7e25b23f8a.md @@ -1,8 +1,8 @@ --- id: 64ab143edad72b7e25b23f8a -title: Крок 36 +title: Step 40 challengeType: 0 -dashedName: step-36 +dashedName: step-40 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md index 65c407e9174..8d90b2e7567 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64ab178206f3237eafcc0ef4.md @@ -1,8 +1,8 @@ --- id: 64ab178206f3237eafcc0ef4 -title: Крок 37 +title: Step 41 challengeType: 0 -dashedName: step-37 +dashedName: step-41 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md index af6dee76ae1..584c0120446 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acebecb7484c8c6a760534.md @@ -1,8 +1,8 @@ --- id: 64acebecb7484c8c6a760534 -title: Крок 38 +title: Step 42 challengeType: 0 -dashedName: step-38 +dashedName: step-42 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md index 0df6d12a707..912088799f4 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64aced3e88b0a38cec824dea.md @@ -1,8 +1,8 @@ --- id: 64aced3e88b0a38cec824dea -title: Крок 39 +title: Step 43 challengeType: 0 -dashedName: step-39 +dashedName: step-43 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md index 8030197eda8..d6b340e5910 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acedb5f59c0c8d43e96aa4.md @@ -1,8 +1,8 @@ --- id: 64acedb5f59c0c8d43e96aa4 -title: Крок 40 +title: Step 44 challengeType: 0 -dashedName: step-40 +dashedName: step-44 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md index 371468e7b22..2927aa25e15 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf1af380a708ded8761f0.md @@ -1,8 +1,8 @@ --- id: 64acf1af380a708ded8761f0 -title: Крок 41 +title: Step 45 challengeType: 0 -dashedName: step-41 +dashedName: step-45 --- # --description-- @@ -204,18 +204,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -240,6 +244,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md index 44820bc1080..8c47159e369 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64acf287857bb38e6dd7ca69.md @@ -1,22 +1,24 @@ --- id: 64acf287857bb38e6dd7ca69 -title: Крок 42 +title: Step 46 challengeType: 0 -dashedName: step-42 +dashedName: step-46 --- # --description-- The next step is to add the logic for increasing or decreasing a player's velocity based on if they move to the left or right of the screen. -Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than 400. +Inside the `animate` function, create an `if` statement where the condition checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. + +You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. # --hints-- -You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than 400. +You should have an `if` statement that checks if the right key was pressed and the player's `x` position is less than `proportionalSize(400)`. Remember that the `this` keyword should not be used here because that is only for the `Player` class and not for the `player` object. ```js -assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*400/); +assert.match(animate.toString(), /keys\.rightKey\.(pressed|pressed\s*===\s*true)\s*&&\s*player\.position\.x\s*<\s*proportionalSize\(\s*400\s*\)/); ``` # --seed-- @@ -168,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md index de77e237805..dfa712b747e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c703f58330b3767399e486.md @@ -1,8 +1,8 @@ --- id: 64c703f58330b3767399e486 -title: Крок 43 +title: Step 47 challengeType: 0 -dashedName: step-43 +dashedName: step-47 --- # --description-- @@ -11,7 +11,7 @@ Inside the `if` statement, assign the number `5` to the player's `x` velocity. # --hints-- -You should assign the number 5 to the player's `x` velocity. +You should assign the number `5` to the player's `x` velocity. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*5\s*;?/); @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,7 +223,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md index dbb622346cf..50bb9396457 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c705fd8969d677066792b8.md @@ -1,15 +1,15 @@ --- id: 64c705fd8969d677066792b8 -title: Крок 44 +title: Step 48 challengeType: 0 -dashedName: step-44 +dashedName: step-48 --- # --description-- -Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than 100. +Add an `else if` statement where the condition checks if the left key was pressed and the player's `x` position is greater than `proportionalSize(100)`. You need to use the `proportionalSize` function here to make sure the player's `x` position is always proportional to the screen size. -Inside the `else if` statement, assign the number -5 to the player's x velocity. +Inside the `else if` statement, assign the number `-5` to the player's `x` velocity. # --hints-- @@ -19,13 +19,13 @@ You should add an `else if` statement to your `animate` function. assert.match(animate.toString(), /else\s+if/); ``` -You should check if the left key was pressed and if the player's `x` position is greater than 100. +You should check if the left key was pressed and if the player's `x` position is greater than `proportionalSize(100)`. ```js -assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*100/); +assert.match(animate.toString(), /keys\.leftKey\.pressed\s*&&\s*player\.position\.x\s*>\s*proportionalSize\(\s*100\s*\)/); ``` -You should assign the number -5 to the player's `x` velocity inside the `else if`. +You should assign the number `-5` to the player's `x` velocity inside the `else if`. ```js assert.match(animate.toString(), /player\.velocity\.x\s*=\s*-5\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md index 8cc5ee45402..1934be67533 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c708fe06b0c3776f90faaf.md @@ -1,8 +1,8 @@ --- id: 64c708fe06b0c3776f90faaf -title: Крок 45 +title: Step 49 challengeType: 0 -dashedName: step-45 +dashedName: step-49 --- # --description-- @@ -25,10 +25,10 @@ const split = animate.toString().split(/\s|\n/); assert.isAbove(split.indexOf('else'), split.indexOf('if')); ``` -You should include an `else` clause that assigns the number 0 to the player's `x` velocity. +You should include an `else` clause that assigns the number `0` to the player's `x` velocity. ```js -assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0;?/); +assert.match(animate.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` # --seed-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,9 +237,9 @@ const animate = () => { --fcc-editable-region-- - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md index 2bd8e633392..be95a9ed587 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70d3bf7504978368da6ad.md @@ -1,8 +1,8 @@ --- id: 64c70d3bf7504978368da6ad -title: Крок 46 +title: Step 50 challengeType: 0 -dashedName: step-46 +dashedName: step-50 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md index 2462ebc35a1..ad46a890b6a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c70f78dbf5667a307a7d90.md @@ -1,8 +1,8 @@ --- id: 64c70f78dbf5667a307a7d90 -title: Крок 47 +title: Step 51 challengeType: 0 -dashedName: step-47 +dashedName: step-51 --- # --description-- @@ -181,18 +181,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -217,6 +221,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md index 971457d96dd..0bc62245d07 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c71235eba6c67adaa9a458.md @@ -1,25 +1,25 @@ --- id: 64c71235eba6c67adaa9a458 -title: Крок 48 +title: Step 52 challengeType: 0 -dashedName: step-48 +dashedName: step-52 --- # --description-- -Inside the `if` statement, set the player's `x` velocity to 0 and the player's `y` velocity to 0. +Inside the `if` statement, set the player's `x` velocity to `0` and the player's `y` velocity to `0`. Below that, add a `return` statement. # --hints-- -You should set the player's `x` velocity to 0. +You should set the player's `x` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.x\s*=\s*0\s*;?/); ``` -You should set the player's `y` velocity to 0. +You should set the player's `y` velocity to `0`. ```js assert.match(movePlayer.toString(), /player\.velocity\.y\s*=\s*0\s*;?/); @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md index f1074d66fb4..fd5e074f80b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7135a9d35797b4bfb01b3.md @@ -1,8 +1,8 @@ --- id: 64c7135a9d35797b4bfb01b3 -title: Крок 49 +title: Step 53 challengeType: 0 -dashedName: step-49 +dashedName: step-53 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md index 63ea5d9f74e..39e1709c26b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c714ec1b844f7bc0723deb.md @@ -1,8 +1,8 @@ --- id: 64c714ec1b844f7bc0723deb -title: Крок 50 +title: Step 54 challengeType: 0 -dashedName: step-50 +dashedName: step-54 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -215,9 +223,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md index f44adb0d53d..5f6bbcc31bc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c715769bab5f7c14f6cd7b.md @@ -1,8 +1,8 @@ --- id: 64c715769bab5f7c14f6cd7b -title: Крок 51 +title: Step 55 challengeType: 0 -dashedName: step-51 +dashedName: step-55 --- # --description-- @@ -180,18 +180,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -216,6 +220,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -227,9 +235,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md index eec08c92524..18d20539301 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7168cba4a4f7c90c26277.md @@ -1,8 +1,8 @@ --- id: 64c7168cba4a4f7c90c26277 -title: Крок 52 +title: Step 56 challengeType: 0 -dashedName: step-52 +dashedName: step-56 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -221,9 +229,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md index 74da936ef1c..ef1e2ee14af 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7173772c2497ce99b474c.md @@ -1,8 +1,8 @@ --- id: 64c7173772c2497ce99b474c -title: Крок 53 +title: Step 57 challengeType: 0 -dashedName: step-53 +dashedName: step-57 --- # --description-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md index d31c0a71049..ce28b2e7ee8 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7202620a5e17d8a3c777d.md @@ -1,8 +1,8 @@ --- id: 64c7202620a5e17d8a3c777d -title: Крок 54 +title: Step 58 challengeType: 0 -dashedName: step-54 +dashedName: step-58 --- # --description-- @@ -196,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -232,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -243,9 +251,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md index b3fd677f557..7553b5a3bcf 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c72e52133d687e8e6a60f6.md @@ -1,8 +1,8 @@ --- id: 64c72e52133d687e8e6a60f6 -title: Крок 55 +title: Step 59 challengeType: 0 -dashedName: step-55 +dashedName: step-59 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md index fcdda64ec43..f69ae8d55ea 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73367cce78a7fd65dd3be.md @@ -1,8 +1,8 @@ --- id: 64c73367cce78a7fd65dd3be -title: Крок 56 +title: Step 60 challengeType: 0 -dashedName: step-56 +dashedName: step-60 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md index 5bd4fe96850..574dd40d018 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c734293def73808e609778.md @@ -1,8 +1,8 @@ --- id: 64c734293def73808e609778 -title: Крок 57 +title: Step 61 challengeType: 0 -dashedName: step-57 +dashedName: step-61 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,9 +227,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md index 02d4f639eab..860719bde4d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c736a531835181349c27d2.md @@ -1,8 +1,8 @@ --- id: 64c736a531835181349c27d2 -title: Крок 58 +title: Step 62 challengeType: 0 -dashedName: step-58 +dashedName: step-62 --- # --description-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md index de9561db1c0..a8d5e05af40 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73981de025581bddb89eb.md @@ -1,8 +1,8 @@ --- id: 64c73981de025581bddb89eb -title: Крок 59 +title: Step 63 challengeType: 0 -dashedName: step-59 +dashedName: step-63 --- # --description-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -225,9 +233,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md index bcb788a5923..a92a271963d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c73df1424422832333a9fa.md @@ -1,8 +1,8 @@ --- id: 64c73df1424422832333a9fa -title: Крок 60 +title: Step 64 challengeType: 0 -dashedName: step-60 +dashedName: step-64 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -218,9 +226,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md index 000028ded39..715d320b1fc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a226587f502c0525927.md @@ -1,8 +1,8 @@ --- id: 64c74a226587f502c0525927 -title: Крок 61 +title: Step 65 challengeType: 0 -dashedName: step-61 +dashedName: step-65 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,9 +228,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md index cdb92d07ec1..2bbb5741491 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74a8a4138c6032241d498.md @@ -1,8 +1,8 @@ --- id: 64c74a8a4138c6032241d498 -title: Крок 62 +title: Step 66 challengeType: 0 -dashedName: step-62 +dashedName: step-66 --- # --description-- @@ -172,18 +172,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -208,6 +212,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md index ef56d2127e1..71ddeb1f7d1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74c293dd7cf03cbd58194.md @@ -1,8 +1,8 @@ --- id: 64c74c293dd7cf03cbd58194 -title: Крок 63 +title: Step 67 challengeType: 0 -dashedName: step-63 +dashedName: step-67 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,9 +236,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md index cf9c5771e86..d36c032c925 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c74e0064a9080443af0796.md @@ -1,13 +1,13 @@ --- id: 64c74e0064a9080443af0796 -title: Крок 64 +title: Step 68 challengeType: 0 -dashedName: step-64 +dashedName: step-68 --- # --description-- -Below that, add a `height` property and assign it the number `40`. +Below that, add a `height` property and assign it the number `proportionalSize(40)`. You need to use the `proportionalSize()` function to make sure the `height` is proportional to the screen size. Remember to use the `this` keyword to access the properties. @@ -17,7 +17,7 @@ You should have a `height` property. ```js const splitter = code.split("if (this.position.x < this.width) {") -assert.match(splitter[1], /this\.height\s*=\s*40\s*;?/); +assert.match(splitter[1], /this\.height\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` # --seed-- @@ -169,18 +169,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -205,6 +209,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,9 +238,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md index d5d02714377..b2225896955 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c750c328e06f0878a9272e.md @@ -1,8 +1,8 @@ --- id: 64c750c328e06f0878a9272e -title: Крок 65 +title: Step 69 challengeType: 0 -dashedName: step-65 +dashedName: step-69 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } } @@ -236,9 +244,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md index c0c712265cb..89fc9c774f7 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7527100b19b09037ce5db.md @@ -1,8 +1,8 @@ --- id: 64c7527100b19b09037ce5db -title: Крок 66 +title: Step 70 challengeType: 0 -dashedName: step-66 +dashedName: step-70 --- # --description-- @@ -175,18 +175,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -211,6 +215,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { @@ -239,9 +247,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md index e73d036a756..f56783e00f9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7538db3e33d09704ab148.md @@ -1,8 +1,8 @@ --- id: 64c7538db3e33d09704ab148 -title: Крок 67 +title: Step 71 challengeType: 0 -dashedName: step-67 +dashedName: step-71 --- # --description-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,9 +241,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md index a863d814fc7..4c086b317ea 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c754f598ca5409d0a08884.md @@ -1,22 +1,22 @@ --- id: 64c754f598ca5409d0a08884 -title: Крок 68 +title: Step 72 challengeType: 0 -dashedName: step-68 +dashedName: step-72 --- # --description-- Inside the `platformPositions`, you will need to add the list of positions for the platforms. -Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `450`. +Add a new object that has an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. # --hints-- -You should have an object with an `x` property with a value of 500 and a `y` property with a value of 450. +You should have an object with an `x` property with a value of `500` and a `y` property with a value of `proportionalSize(450)`. You are using the `proportionalSize()` function here to make sure the `y` value is proportional to the screen size. ```js -assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*450\s*}/); +assert.match(code, /{\s*x\s*:\s*500\s*,\s*y\s*:\s*proportionalSize\(\s*450\s*\)\s*}/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md index 754958b0ae7..f4fd39bde3b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c755bf0034b20a428a4a1b.md @@ -1,21 +1,21 @@ --- id: 64c755bf0034b20a428a4a1b -title: Крок 69 +title: Step 73 challengeType: 0 -dashedName: step-69 +dashedName: step-73 --- # --description-- -Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `400`. +Below that, add another object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. # --hints-- -You should have an object with an `x` property with a value of 700 and a `y` property with a value of 400. +You should have an object with an `x` property with a value of `700` and a `y` property with a value of `proportionalSize(400)`. ```js -assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*400.*}/); +assert.match(code, /{.*x\s*:\s*700.*y\s*:\s*proportionalSize\(\s*400\s*\).*}/); ``` # --seed-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -226,7 +234,7 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, + { x: 500, y: proportionalSize(450) }, ]; @@ -237,9 +245,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md index ffcc54be81a..d263bdf54b3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7561d44e2300a90a38ab6.md @@ -1,8 +1,8 @@ --- id: 64c7561d44e2300a90a38ab6 -title: Крок 70 +title: Step 74 challengeType: 0 -dashedName: step-70 +dashedName: step-74 --- # --description-- @@ -11,16 +11,16 @@ dashedName: step-70 Add the rest of the platform positions to the `platformPositions` array with the following values: ```js -x=850 y=350 -x=900 y=350 -x=1050 y=150 -x=2500 y=450 -x=2900 y=400 -x=3150 y=350 -x=3900 y=450 -x=4200 y=400 -x=4400 y=200 -x=4700 y=150 +x=850 y=proportionalSize(350) +x=900 y=proportionalSize(350) +x=1050 y=proportionalSize(150) +x=2500 y=proportionalSize(450) +x=2900 y=proportionalSize(400) +x=3150 y=proportionalSize(350) +x=3900 y=proportionalSize(450) +x=4200 y=proportionalSize(400) +x=4400 y=proportionalSize(200) +x=4700 y=proportionalSize(150) ``` # --hints-- @@ -29,18 +29,18 @@ You should include the rest of the values in the `platformPositions` array. ```js const platformPositionsClone = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; assert.deepEqual(platformPositions, platformPositionsClone); @@ -195,18 +195,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -231,6 +235,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -241,7 +249,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -254,8 +262,8 @@ const player = new Player(); --fcc-editable-region-- const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, ]; @@ -266,9 +274,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md index 67ec84c83c9..303311211d4 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c7573fd2265f0b1c77e2ec.md @@ -1,8 +1,8 @@ --- id: 64c7573fd2265f0b1c77e2ec -title: Крок 71 +title: Step 75 challengeType: 0 -dashedName: step-71 +dashedName: step-75 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -254,9 +262,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md index 950e3eb18fa..e0e1e7204cc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c758ab7352130b775df8c4.md @@ -1,8 +1,8 @@ --- id: 64c758ab7352130b775df8c4 -title: Крок 72 +title: Step 76 challengeType: 0 -dashedName: step-72 +dashedName: step-76 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; --fcc-editable-region-- @@ -250,9 +258,9 @@ const animate = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md index 2d199656c62..545d5ddcd3d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c764dd9071050d0a2c1473.md @@ -1,8 +1,8 @@ --- id: 64c764dd9071050d0a2c1473 -title: Крок 73 +title: Step 77 challengeType: 0 -dashedName: step-73 +dashedName: step-77 --- # --description-- @@ -18,19 +18,19 @@ Inside the callback function, add a `platform` parameter and for the body of the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should add a `platform` parameter to the callback function. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*(.*?)\s*}?\s*\)\s*;?/); ``` You should call the `draw` method on each `platform`. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{?\s*platform\.draw\(\s*\)\s*;?\s*}?\s*\)\s*;?/); ``` # --seed-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,18 +247,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -267,9 +275,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md index 414d18d57c6..01c426e728d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9bab6998128282da063f9.md @@ -1,8 +1,8 @@ --- id: 64c9bab6998128282da063f9 -title: Крок 74 +title: Step 78 challengeType: 0 -dashedName: step-74 +dashedName: step-78 --- # --description-- @@ -170,18 +170,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -206,6 +210,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -216,7 +224,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -227,18 +235,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -255,9 +263,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md index e47dab77534..8b3cb1b4f83 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9db021d4d912906878f3a.md @@ -1,8 +1,8 @@ --- id: 64c9db021d4d912906878f3a -title: Крок 75 +title: Step 79 challengeType: 0 -dashedName: step-75 +dashedName: step-79 --- # --description-- @@ -16,13 +16,13 @@ Inside the loop, use the subtraction assignment operator to subtract 5 from the You should have a `forEach` loop that iterates through the `platforms` array. ```js -assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\);?/); +assert.match(code, /if\s*\(.*\)\s*{\s+platforms\.forEach\(\s*(\(.*\)|[^\s()]+)\s*=>\s*{\s*(.*?)\s*}\s*\)\s*;?/); ``` You should use the subtraction assignment operator to subtract 5 from the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md index ad4e8b47a9d..d9b122d8549 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9dc4bd63a92295347c449.md @@ -1,8 +1,8 @@ --- id: 64c9dc4bd63a92295347c449 -title: Крок 76 +title: Step 80 challengeType: 0 -dashedName: step-76 +dashedName: step-80 --- # --description-- @@ -18,7 +18,7 @@ Inside the loop, use the addition assignment operator to add 5 to the platform's You should have a condition that checks if the left key was pressed and if `isCheckpointCollisionDetectionActive` is true. ```js -assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\);\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\);?/s); +assert.match(code, /if\s*\(\s*keys\.rightKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*-=\s*5\s*;\s*}\s*\)\s*;?\s*}\s*else\s+if\s*\(\s*keys\.leftKey\.pressed\s*&&\s*isCheckpointCollisionDetectionActive\s*\)\s*{.*}\s*\)\s*;?/s); ``` @@ -31,7 +31,7 @@ assert.match(code, /else\s+if\s*\(.*\)\s*{\s*platforms\.forEach\(\s*(\(\s*platfo You should use the addition assignment operator to add 5 to the platform's `x` position. ```js -assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\);?/); +assert.match(code, /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*{\s*platform\.position\.x\s*\+=\s*5\s*;?\s*}\s*\)\s*;?/); ``` # --seed-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md index 01406bd618a..0aa52253c4b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e4cc5f06902dc75dc8f4.md @@ -1,8 +1,8 @@ --- id: 64c9e4cc5f06902dc75dc8f4 -title: Крок 77 +title: Step 81 challengeType: 0 -dashedName: step-77 +dashedName: step-81 --- # --description-- @@ -26,7 +26,7 @@ Your callback function should have a `platform` parameter. ```js const splitter = code.split("platform.position.x += 5;") -assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\);?/); +assert.match(splitter[1], /platforms\.forEach\(\s*(\(\s*platform\s*\)|platform)\s*=>\s*\{\s*\}\s*\)\s*;?/); ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -235,18 +243,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,9 +271,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md index ff3c5856e39..2a72a101773 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9e90c433fde2e870285a3.md @@ -1,8 +1,8 @@ --- id: 64c9e90c433fde2e870285a3 -title: Крок 78 +title: Step 82 challengeType: 0 -dashedName: step-78 +dashedName: step-82 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md index c599932f49d..f19e076fca6 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9efea385ca536bf467a7c.md @@ -1,8 +1,8 @@ --- id: 64c9efea385ca536bf467a7c -title: Крок 79 +title: Step 83 challengeType: 0 -dashedName: step-79 +dashedName: step-83 --- # --description-- @@ -167,18 +167,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -203,6 +207,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -213,7 +221,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -224,18 +232,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -252,9 +260,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md index 509d4d40acb..dc6d63565b3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fa51209ab5395d524cce.md @@ -1,8 +1,8 @@ --- id: 64c9fa51209ab5395d524cce -title: Крок 80 +title: Step 84 challengeType: 0 -dashedName: step-80 +dashedName: step-84 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md index 5d84d8bcca0..a68f265ff2d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64c9fe7b2ffa3539fbf82d32.md @@ -1,8 +1,8 @@ --- id: 64c9fe7b2ffa3539fbf82d32 -title: Крок 81 +title: Step 85 challengeType: 0 -dashedName: step-81 +dashedName: step-85 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md index 154eaa8f9ba..bf5ba8ab818 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cab4d06512c95234256cbb.md @@ -1,8 +1,8 @@ --- id: 64cab4d06512c95234256cbb -title: Крок 82 +title: Step 86 challengeType: 0 -dashedName: step-82 +dashedName: step-86 --- # --description-- @@ -22,7 +22,7 @@ assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s* You should assign the number `0` to the player's `y` velocity followed by a `return` statement inside the body of the `if` statement. ```js -assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\};?/); +assert.match(code, /if\s*\(\s*collisionDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2)\s*\)\s*\)\s*\{\s*player\.velocity\.y\s*=\s*0\s*;?\s*return\s*;?\s*\}\s*;?/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,18 +239,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -259,9 +267,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md index 870f30e32be..a6b0501236d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caea41a4199e54253c60ca.md @@ -1,8 +1,8 @@ --- id: 64caea41a4199e54253c60ca -title: Крок 83 +title: Step 87 challengeType: 0 -dashedName: step-83 +dashedName: step-87 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md index 5a2e5b2130d..7efda9045cc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeb134c3cdc5498cd75b9.md @@ -1,8 +1,8 @@ --- id: 64caeb134c3cdc5498cd75b9 -title: Крок 84 +title: Step 88 challengeType: 0 -dashedName: step-84 +dashedName: step-88 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md index 48e89b4e2dc..a4531f7b311 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caeeae2fa57756035d6012.md @@ -1,8 +1,8 @@ --- id: 64caeeae2fa57756035d6012 -title: Крок 85 +title: Step 89 challengeType: 0 -dashedName: step-85 +dashedName: step-89 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md index 12ab20a9476..5874bb8eb4d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf1be15606d5814c3387b.md @@ -1,8 +1,8 @@ --- id: 64caf1be15606d5814c3387b -title: Крок 86 +title: Step 90 challengeType: 0 -dashedName: step-86 +dashedName: step-90 --- # --description-- @@ -183,18 +183,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -219,6 +223,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -229,7 +237,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,18 +248,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -268,9 +276,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md index 8af5939759c..28877ef405a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64caf237baef43587be6d860.md @@ -1,8 +1,8 @@ --- id: 64caf237baef43587be6d860 -title: Крок 87 +title: Step 91 challengeType: 0 -dashedName: step-87 +dashedName: step-91 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,18 +231,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -251,9 +259,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md index aa45e8328ba..d7376bb2d78 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb24c224ac2c61fa1c70aa.md @@ -1,8 +1,8 @@ --- id: 64cb24c224ac2c61fa1c70aa -title: Крок 88 +title: Step 92 challengeType: 0 -dashedName: step-88 +dashedName: step-92 --- # --description-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,18 +241,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -261,9 +269,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md index a81698df9db..7fbf61939fb 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb262dd91ecc62998736af.md @@ -1,8 +1,8 @@ --- id: 64cb262dd91ecc62998736af -title: Крок 89 +title: Step 93 challengeType: 0 -dashedName: step-89 +dashedName: step-93 --- # --description-- @@ -16,7 +16,7 @@ Start by creating a new `class` called `CheckPoint`. You should have a `class` called `CheckPoint`. ```js -assert.match(code, /\s*class\s*CheckPoint\s*{\s*};?/); +assert.match(code, /\s*class\s*CheckPoint\s*{\s*}\s*;?/); ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,18 +237,18 @@ class Platform { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -257,9 +265,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md index da75222e55c..9c4c2d9490f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb26e84dd0b56313ba0c6e.md @@ -1,13 +1,13 @@ --- id: 64cb26e84dd0b56313ba0c6e -title: Крок 90 +title: Step 94 challengeType: 0 -dashedName: step-90 +dashedName: step-94 --- # --description-- -Inside that `CheckPoint` class, add a constructor with `x` and `y` parameters. +Inside that `CheckPoint` class, add a constructor with `x`, `y` and `z` parameters. # --hints-- @@ -18,10 +18,10 @@ You should have a `constructor` method inside the `CheckPoint` class. assert.match(code, /\s*constructor\s*\(.*\)\s*{\s*}/); ``` -Your `constructor` should have `x` and `y` parameters. +Your `constructor` should have `x`, `y` and `z` parameters in that order. ```js -assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*\)\s*{\s*};?/); +assert.match(code, /\s*constructor\s*\(\s*x\s*,\s*y\s*,\s*z\s*\)\s*{\s*}\s*;?/); ``` # --seed-- @@ -173,18 +173,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -209,6 +213,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -219,7 +227,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -238,18 +246,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -266,9 +274,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md index 9aebb372040..2d4ad2dc17c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2a87057eb5655c66d1c2.md @@ -1,8 +1,8 @@ --- id: 64cb2a87057eb5655c66d1c2 -title: Крок 91 +title: Step 95 challengeType: 0 -dashedName: step-91 +dashedName: step-95 --- # --description-- @@ -25,7 +25,7 @@ The `this.position` property should be an object with the `x` and `y` coordinate ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\};?/); +assert.match(splitter[2], /this\.position\s*=\s*\{\s*x\s*,\s*y\s*,?\s*\}\s*;?/); ``` # --seed-- @@ -177,18 +177,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -213,6 +217,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -223,7 +231,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -234,7 +242,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { }; }; @@ -244,18 +252,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -272,9 +280,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md index b0246312f07..882f5359853 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2da32f8443669fd4e725.md @@ -1,15 +1,15 @@ --- id: 64cb2da32f8443669fd4e725 -title: Крок 92 +title: Step 96 challengeType: 0 -dashedName: step-92 +dashedName: step-96 --- # --description-- The next step is to add the `width` and `height` to the `CheckPoint` class. -The `width` and `height` should be 40 and 70 respectively. +The `width` and `height` should be `proportionalSize(40)` and `proportionalSize(70)` respectively. # --hints-- @@ -17,7 +17,7 @@ You should have a `width` property inside the `CheckPoint` class. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width;?/); +assert.match(splitter[2], /this\.width\s*;?/); ``` You should have a `height` property inside the `CheckPoint` class. @@ -27,18 +27,18 @@ const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this assert.match(splitter[2], /this\.height\s*;?/); ``` -You should assign the `width` property to 40. +You should assign the `width` property to `proportionalSize(40)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.width\s*=\s*40\s*;?/); +assert.match(splitter[2], /this\.width\s*=\s*proportionalSize\(\s*40\s*\)\s*;?/); ``` -You should assign the `height` property to 70. +You should assign the `height` property to `proportionalSize(70)`. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height);") -assert.match(splitter[2], /this\.height\s*=\s*70\s*;?/); +assert.match(splitter[2], /this\.height\s*=\s*proportionalSize\(\s*70\s*\)\s*;?/); ``` # --seed-- @@ -190,18 +190,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -226,6 +230,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -236,7 +244,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -247,7 +255,7 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, @@ -261,18 +269,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -289,9 +297,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md index 7562cb8448f..21101bab723 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2e5bdfb23a67272a07c7.md @@ -1,8 +1,8 @@ --- id: 64cb2e5bdfb23a67272a07c7 -title: Крок 93 +title: Step 98 challengeType: 0 -dashedName: step-93 +dashedName: step-98 --- # --description-- @@ -26,14 +26,14 @@ Your `draw` method should have a `fillStyle` property. ```js const splitter = code.split("ctx.fillRect(this.position.x, this.position.y, this.width, this.height)") -assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1;?/); +assert.match(splitter[2], /draw\(\s*\)\s*\{\s*ctx\.fillStyle\s*=\s*('|")#f1be32\1\s*;?/); ``` Your `draw` method should have a `fillRect` method. ```js const splitter = code.split('#f1be32') -assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\);?/); +assert.match(splitter[1], /ctx\.fillRect\(\s*this\.position\.x\s*,\s*this\.position\.y\s*,\s*this\.width\s*,\s*this\.height\s*\)\s*;?/); ``` # --seed-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -242,13 +250,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; }; @@ -258,18 +267,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -286,9 +295,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md index 1fff8af8ed0..00176126504 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb2ff0c31b0f67a6d76a47.md @@ -1,18 +1,20 @@ --- id: 64cb2ff0c31b0f67a6d76a47 -title: Крок 94 +title: Step 99 challengeType: 0 -dashedName: step-94 +dashedName: step-99 --- # --description-- The last method you will need to add to the `CheckPoint` class is the `claim` method. -Inside the `claim` method, assign 0 to the `width` and `height` properties of the `CheckPoint` instance. +Inside the `claim` method, assign `0` to the `width` and `height` properties of the `CheckPoint` instance. Below those properties, assign `Infinity` to the `y` position. +Lastly, assign `true` to the `claimed` property. + # --hints-- Your `CheckPoint` class should have a `claim` method. @@ -21,13 +23,13 @@ Your `CheckPoint` class should have a `claim` method. assert.match(code, /\s*claim\s*\(\s*\)\s*{\s*(.*\S)?\s*}\s*;/s); ``` -Your `claim` method should have a `width` property set to 0. +Your `claim` method should have a `width` property set to `0`. ```js assert.match(code, /\s*this\.width\s*=\s*0\s*;?/); ``` -Your `claim` method should have a `height` property set to 0. +Your `claim` method should have a `height` property set to `0`. ```js assert.match(code, /\s*this\.height\s*=\s*0\s*;?/); @@ -39,6 +41,12 @@ You should assign `Infinity` to the `y` position. assert.match(code, /\s*this\.position\.y\s*=\s*Infinity\s*;?/); ``` +You should assign `true` to the `claimed` property. + +```js +assert.match(code, /\s*this\.claimed\s*=\s*true\s*;?/); +``` + # --seed-- ## --seed-contents-- @@ -188,18 +196,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -224,6 +236,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -234,7 +250,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -245,13 +261,14 @@ class Platform { --fcc-editable-region-- class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,18 +283,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -294,9 +311,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md index 04ab304a5ff..26fa7e4c5ab 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb30b8e4719a67fe14f364.md @@ -1,8 +1,8 @@ --- id: 64cb30b8e4719a67fe14f364 -title: Крок 95 +title: Step 100 challengeType: 0 -dashedName: step-95 +dashedName: step-100 --- # --description-- @@ -12,9 +12,9 @@ Use `const` to create a new array called `checkpointPositions`. Inside that array, add an object for each of the following positions: ```js -x: 1170, y: 80 -x: 2900, y: 330 -x: 4800, y: 80 + x: 1170, y: proportionalSize(80), z: 1 + x: 2900, y: proportionalSize(330), z: 2 + x: 4800, y: proportionalSize(80), z: 3 ``` # --hints-- @@ -31,22 +31,22 @@ You should have three objects inside the `checkpointPositions` array. assert.lengthOf(checkpointPositions, 3); ``` -You should have an object with an `x` property set to 1170 and a `y` property set to 80. +You should have an object with an `x` property set to `1170`, `y` property set to `proportionalSize(80)`, and `z` property set to `1`. ```js -assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: 80 }); +assert.deepStrictEqual(checkpointPositions[0], { x: 1170, y: proportionalSize(80), z: 1 }); ``` -You should have an object with an `x` property set to 2900 and a `y` property set to 330. +You should have an object with an `x` property set to `2900`, `y` property set to `proportionalSize(330)`, and a `z` property set to `2`. ```js -assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: 330 }); +assert.deepStrictEqual(checkpointPositions[1], { x: 2900, y: proportionalSize(330), z: 2 }); ``` -You should have an object with an `x` property set to 4800 and a `y` property set to 80. +You should have an object with an `x` property set to `4800`, `y` property set to `proportionalSize(80)`, and a `z` property set to `3`. ```js -assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: 80 }); +assert.deepStrictEqual(checkpointPositions[2], { x: 4800, y: proportionalSize(80), z: 3 }); ``` # --seed-- @@ -198,18 +198,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -234,6 +238,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -244,7 +252,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -253,13 +261,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -270,6 +279,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -277,18 +287,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -309,9 +319,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md index ae613988679..1110cb36177 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb34c01b3d856a9a59261d.md @@ -1,8 +1,8 @@ --- id: 64cb34c01b3d856a9a59261d -title: Крок 96 +title: Step 101 challengeType: 0 -dashedName: step-96 +dashedName: step-101 --- # --description-- @@ -11,7 +11,7 @@ The next step is to create a list of new `checkpoint` instances using the `Check Start by creating a new `const` variable called `checkpoints` and assign it `checkpointPositions.map()`. -For the map callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x` and `checkpoint.y` values passed in as arguments. +For the `map` callback function, pass in `checkpoint` for the parameter and implicitly return the creation of a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments. # --hints-- @@ -29,10 +29,10 @@ assert.match(code, /\s*const\s+checkpoints\s*=\s*checkpointPositions\.map\s*\(\s ``` -You should implicitly return a new `CheckPoint` instance. +You should implicitly return a new `CheckPoint` instance with the `checkpoint.x`, `checkpoint.y` and `checkpoint.z` values passed in as arguments in that order. ```js -assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*\)\s*\)\s*;?/); +assert.match(code, /\s*checkpointPositions\.map\s*\(\s*(\(\s*checkpoint\s*\)|checkpoint)\s*=>\s*new\s+CheckPoint\s*\(\s*checkpoint\.x\s*,\s*checkpoint\.y\s*,\s*checkpoint\.z\s*\)\s*\)\s*;?/); ``` # --seed-- @@ -184,18 +184,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -220,6 +224,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -230,7 +238,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -239,13 +247,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -256,24 +265,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,9 +291,9 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; --fcc-editable-region-- @@ -300,9 +310,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md index eace22a29b9..0f20baeab9a 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb3f62b10c336bada1c70c.md @@ -1,8 +1,8 @@ --- id: 64cb3f62b10c336bada1c70c -title: Крок 97 +title: Step 102 challengeType: 0 -dashedName: step-97 +dashedName: step-102 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,32 +236,34 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; ctx.fillRect(this.position.x, this.position.y, this.width, this.height); } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } claim() { this.width = 0; this.height = 0; this.position.y = Infinity; - } -} - -class CheckPoint { - constructor(x, y) { - this.position = { - x, - y, - }; - this.width = 40; - this.height = 70; - }; - - draw() { - ctx.fillStyle = "#f1be32"; - ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -281,13 +291,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -304,9 +314,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md index be662bbf905..d13a7eb5ed3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb472593e3be6d10a7c13b.md @@ -1,8 +1,8 @@ --- id: 64cb472593e3be6d10a7c13b -title: Крок 98 +title: Step 103 challengeType: 0 -dashedName: step-98 +dashedName: step-103 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md index 547b27c2222..6daf63db3d9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb480723790d6d727b8ef5.md @@ -1,8 +1,8 @@ --- id: 64cb480723790d6d727b8ef5 -title: Крок 99 +title: Step 104 challengeType: 0 -dashedName: step-99 +dashedName: step-104 --- # --description-- @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,6 +263,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -261,18 +271,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md index d76ed1db523..9670a73667e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb48e36c9ad56dd7a523f4.md @@ -1,8 +1,8 @@ --- id: 64cb48e36c9ad56dd7a523f4 -title: Крок 100 +title: Step 105 challengeType: 0 -dashedName: step-100 +dashedName: step-105 --- # --description-- @@ -22,7 +22,7 @@ assert.isFunction(showCheckpointScreen); Your `showCheckpointScreen` function should have a `msg` parameter. ```js -assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*\(?\s*msg\s*\)?\s*=>\s*{/); +assert.match(code, /\s*const\s+showCheckpointScreen\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*{/); ``` # --seed-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,6 +255,7 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; @@ -253,18 +263,18 @@ class CheckPoint { const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -274,13 +284,13 @@ const platforms = platformPositions.map( const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -297,9 +307,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md index 8e3aa8a0e2c..c2f4268dba0 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4978631a4f6e3e1b964d.md @@ -1,8 +1,8 @@ --- id: 64cb4978631a4f6e3e1b964d -title: Крок 101 +title: Step 106 challengeType: 0 -dashedName: step-101 +dashedName: step-106 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md index 64130cfd754..e647743e443 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4e676c156f7332f40db7.md @@ -1,8 +1,8 @@ --- id: 64cb4e676c156f7332f40db7 -title: Крок 102 +title: Step 107 challengeType: 0 -dashedName: step-102 +dashedName: step-107 --- # --description-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md index cd2a5d8f29e..71006ed6e31 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb4ebdc75b3a73a43da5ec.md @@ -1,8 +1,8 @@ --- id: 64cb4ebdc75b3a73a43da5ec -title: Крок 103 +title: Step 108 challengeType: 0 -dashedName: step-103 +dashedName: step-108 --- # --description-- @@ -194,18 +194,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -230,6 +234,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -240,7 +248,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -249,13 +257,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -266,24 +275,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -291,13 +301,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -314,9 +324,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md index d395632adc9..7739d08bdfc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb50fd95831a745ea60d13.md @@ -1,15 +1,15 @@ --- id: 64cb50fd95831a745ea60d13 -title: Крок 104 +title: Step 109 challengeType: 0 -dashedName: step-104 +dashedName: step-109 --- # --description-- The last few steps involve updating the `animate` function to display the checkpoint screen when the player reaches a checkpoint. -Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, and `index` for the parameters. +Start by adding a `forEach` to the `checkpoints` array. For the callback function, use `checkpoint`, `index` and `checkpoints` for the parameters. # --hints-- @@ -20,11 +20,11 @@ const splitter = code.split("player.velocity.y = gravity;") assert.match(splitter[1], /checkpoints\.forEach\(/); ``` -Your callback function should have a `checkpoint` parameter and `index`. +Your callback function should have `checkpoint`, `index` and `checkpoints` parameters in that order. ```js const splitter = code.split("player.velocity.y = gravity;") -assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*\)\s*=>\s*\{/); +assert.match(splitter[1], /checkpoints\.forEach\(\s*\(\s*checkpoint\s*,\s*index\s*,\s*checkpoints\s*\)\s*=>\s*\{/); ``` # --seed-- @@ -176,18 +176,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -212,6 +216,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -222,7 +230,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -231,13 +239,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -248,24 +257,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -273,13 +283,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -296,9 +306,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md index ad9e16f7515..be957205c33 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb522509ffb274daf9fd9e.md @@ -1,8 +1,8 @@ --- id: 64cb522509ffb274daf9fd9e -title: Крок 105 +title: Step 110 challengeType: 0 -dashedName: step-105 +dashedName: step-110 --- # --description-- @@ -174,18 +174,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -210,6 +214,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -220,7 +228,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -229,13 +237,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -246,24 +255,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -271,13 +281,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -294,9 +304,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -351,7 +361,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { }); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md index 29fffc4cba7..d2904f5090e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb583dadb33a77595797bd.md @@ -1,8 +1,8 @@ --- id: 64cb583dadb33a77595797bd -title: Крок 106 +title: Step 111 challengeType: 0 -dashedName: step-106 +dashedName: step-111 --- # --description-- @@ -11,7 +11,7 @@ Add another boolean expression that checks if the player's `position.y` is great Below that statement, add another boolean expression that checks if the player's `position.y` plus the player's `height` is less than or equal to the checkpoint's `position.y` plus the checkpoint's `height`. -For the last array item, add the `isCheckpointCollisionDetectionActive` variable. +Below that statement, add the `isCheckpointCollisionDetectionActive` variable. # --hints-- @@ -185,18 +185,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -221,6 +225,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -231,7 +239,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -240,13 +248,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -257,24 +266,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -282,13 +292,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -305,9 +315,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -362,7 +372,7 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules =[ player.position.x >= checkpoint.position.x, diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md index 8d12fad5a9f..b5af6d28b69 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/64cb5d1d48532b79b4e7ef6c.md @@ -1,8 +1,8 @@ --- id: 64cb5d1d48532b79b4e7ef6c -title: Крок 107 +title: Step 113 challengeType: 0 -dashedName: step-107 +dashedName: step-113 --- # --description-- @@ -16,7 +16,7 @@ Make sure to use the `every` method for this. You should create an empty `if` statement with the condition `checkpointDetectionRules.every((rule) => rule)`. ```js -assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*checkpointDetectionRules\.every\(\s*(?:\(\s*(.+)\s*\)\s*=>\s*\1|([^\s()]+)\s*=>\s*\2\s*)\s*\)\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -345,13 +355,16 @@ const animate = () => { --fcc-editable-region-- - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; }); @@ -359,7 +372,6 @@ const animate = () => { --fcc-editable-region-- } - const keys = { rightKey: { pressed: false diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md index ccaefaf2276..fd993364550 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/6507512fe521de40085b8831.md @@ -1,8 +1,8 @@ --- id: 6507512fe521de40085b8831 -title: Крок 108 +title: Step 114 challengeType: 0 -dashedName: step-108 +dashedName: step-114 --- # --description-- @@ -14,7 +14,7 @@ Inside the `if` statement, call the `claim` method on the `checkpoint` object. You should call the `claim()` method on the `checkpoint` object. ```js -assert.match(code, /checkpoint\.claim\(\s*\);?/) +assert.match(code, /checkpoint\.claim\(\s*\)\s*;?/) ``` # --seed-- @@ -166,18 +166,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -202,6 +206,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -212,7 +220,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -221,13 +229,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -238,24 +247,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -263,13 +273,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -286,9 +296,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -341,13 +351,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; --fcc-editable-region-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md index ba14d66d099..051e7974e36 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650755908a8071409ab9e09e.md @@ -1,8 +1,8 @@ --- id: 650755908a8071409ab9e09e -title: Крок 109 +title: Step 115 challengeType: 0 -dashedName: step-109 +dashedName: step-115 --- # --description-- @@ -16,7 +16,7 @@ Start by adding an `if` statement that checks if the `index` is equal to the len You should have an empty `if` statement with the condition `index === checkpoints.length - 1` ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*\}\s*;?/) ``` # --seed-- @@ -168,18 +168,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -204,6 +208,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -214,7 +222,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -223,13 +231,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -240,24 +249,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -265,13 +275,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -288,9 +298,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -343,13 +353,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md index 6e2722bd58e..95438a380ba 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650756e20cffbe41305a0dde.md @@ -1,8 +1,8 @@ --- id: 650756e20cffbe41305a0dde -title: Крок 110 +title: Step 116 challengeType: 0 -dashedName: step-110 +dashedName: step-116 --- # --description-- @@ -18,13 +18,13 @@ Lastly, you will need to call the `movePlayer` function and pass in the string ` You should set `isCheckpointCollisionDetectionActive` to false inside the `if` statement. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached the final checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\);?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+the\s+final\s+checkpoint!\1\s*\)\s*;?/) ``` You should call the `movePlayer` function and pass in the provided arguments. @@ -182,18 +182,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -218,6 +222,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -228,7 +236,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -237,13 +245,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -254,24 +263,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -279,13 +289,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -302,9 +312,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -357,13 +367,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md index 1495c3ac170..f60366890bc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/650757918a9e97418dc3d71a.md @@ -1,8 +1,8 @@ --- id: 650757918a9e97418dc3d71a -title: Крок 111 +title: Step 117 challengeType: 0 -dashedName: step-111 +dashedName: step-117 --- # --description-- @@ -20,13 +20,13 @@ Congratulations! You have completed the platformer game project! You should add an `else if` clause to check is the player's `x` position is greater than or equal to the checkpoint's `x` position and less than or equal to the checkpoint's `x` position plus `40`. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*/) ``` You should call the `showCheckpointScreen` function and pass in "You reached a checkpoint!" as an argument. ```js -assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\);?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\);?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\);?\s*\};?/) +assert.match(code, /if\s*\(\s*index\s*===\s*checkpoints\.length\s*-\s*1\s*\)\s*\{\s*isCheckpointCollisionDetectionActive\s*=\s*false\s*;?\s*showCheckpointScreen\(\s*("|'|`)You reached the final checkpoint!\1\s*\)\s*;?\s*movePlayer\(\s*("|'|`)ArrowRight\2\s*,\s*0\s*,\s*false\s*\)\s*;?\s*\}\s*else\s+if\s*\(\s*player\.position\.x\s*>=\s*checkpoint\.position\.x\s*&&\s*player\.position\.x\s*<=\s*checkpoint\.position\.x\s\+\s*40\s*\)\s*\{\s*showCheckpointScreen\(\s*("|'|`)You\s+reached\s+a\s*checkpoint!\3\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- @@ -178,18 +178,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -214,6 +218,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -224,7 +232,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -233,13 +241,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -250,24 +259,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -275,13 +285,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -298,9 +308,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -353,13 +363,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { @@ -594,18 +607,22 @@ canvas.height = innerHeight; const gravity = 0.5; let isCheckpointCollisionDetectionActive = true; +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + class Player { constructor() { this.position = { - x: 10, - y: 400, + x: proportionalSize(10), + y: proportionalSize(400), }; this.velocity = { x: 0, y: 0, }; - this.width = 40; - this.height = 40; + this.width = proportionalSize(40); + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#99c9ff"; @@ -630,6 +647,10 @@ class Player { if (this.position.x < this.width) { this.position.x = this.width; } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } } } @@ -640,7 +661,7 @@ class Platform { y, }; this.width = 200; - this.height = 40; + this.height = proportionalSize(40); } draw() { ctx.fillStyle = "#acd157"; @@ -649,13 +670,14 @@ class Platform { } class CheckPoint { - constructor(x, y) { + constructor(x, y, z) { this.position = { x, y, }; - this.width = 40; - this.height = 70; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; }; draw() { @@ -666,24 +688,25 @@ class CheckPoint { this.width = 0; this.height = 0; this.position.y = Infinity; + this.claimed = true; } }; const player = new Player(); const platformPositions = [ - { x: 500, y: 450 }, - { x: 700, y: 400 }, - { x: 850, y: 350 }, - { x: 900, y: 350 }, - { x: 1050, y: 150 }, - { x: 2500, y: 450 }, - { x: 2900, y: 400 }, - { x: 3150, y: 350 }, - { x: 3900, y: 450 }, - { x: 4200, y: 400 }, - { x: 4400, y: 200 }, - { x: 4700, y: 150 } + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, ]; const platforms = platformPositions.map( @@ -691,13 +714,13 @@ const platforms = platformPositions.map( ); const checkpointPositions = [ - { x: 1170, y: 80 }, - { x: 2900, y: 330 }, - { x: 4800, y: 80 }, + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, ]; const checkpoints = checkpointPositions.map( - checkpoint => new CheckPoint(checkpoint.x, checkpoint.y) + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) ); const animate = () => { @@ -714,9 +737,9 @@ const animate = () => { player.update(); - if (keys.rightKey.pressed && player.position.x < 400) { + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { player.velocity.x = 5; - } else if (keys.leftKey.pressed && player.position.x > 100) { + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { player.velocity.x = -5; } else { player.velocity.x = 0; @@ -769,13 +792,16 @@ const animate = () => { }; }); - checkpoints.forEach((checkpoint, index) => { + checkpoints.forEach((checkpoint, index, checkpoints) => { const checkpointDetectionRules = [ player.position.x >= checkpoint.position.x, player.position.y >= checkpoint.position.y, player.position.y + player.height <= checkpoint.position.y + checkpoint.height, - isCheckpointCollisionDetectionActive + isCheckpointCollisionDetectionActive, + player.position.x - player.width <= + checkpoint.position.x - checkpoint.width + player.width * 0.9, + index === 0 || checkpoints[index - 1].claimed === true, ]; if (checkpointDetectionRules.every((rule) => rule)) { diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md new file mode 100644 index 00000000000..19e346a10a1 --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afeb7ab6867b43dacbf32b.md @@ -0,0 +1,187 @@ +--- +id: 65afeb7ab6867b43dacbf32b +title: Step 10 +challengeType: 0 +dashedName: step-10 +--- + +# --description-- + +As you are designing the game, you will need to make sure that the size of the elements in the game are responsive and adapt to different screen sizes. + +Start by creating an arrow function called `proportionalSize` that takes in a `size` parameter. + +# --hints-- + +`proportionalSize` should be a function. + +```js +assert.isFunction(proportionalSize); +``` + +Your `proportionalSize` function should use arrow syntax. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*.*\s*\)?\s*=>/); +``` + +Your `proportionalSize` function should have a `size` parameter. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*\(?\s*size\s*\)?\s*=>/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                                +

                                                freeCodeCamp Code Warrior

                                                +

                                                + Help the main player navigate to the yellow checkpoints. +

                                                +

                                                + Use the keyboard arrows to move the player around. +

                                                +

                                                You can also use the spacebar to jump.

                                                + +
                                                + +
                                                +
                                                + +
                                                +

                                                Congrats!

                                                +

                                                You reached the last checkpoint.

                                                +
                                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- + +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md new file mode 100644 index 00000000000..e1e3b2f36ad --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65afec8f02423144ef136a94.md @@ -0,0 +1,183 @@ +--- +id: 65afec8f02423144ef136a94 +title: Step 11 +challengeType: 0 +dashedName: step-11 +--- + +# --description-- + +The `width` and the `height` of the main player, platforms and checkpoints will be proportional sized relative to the `innerHeight` of the the browser screen. The goal is to make the game responsive and visually consistent across different screen sizes. + +Inside your `proportionalSize` function, you will need to return a ternary that checks if `innerHeight` is less than `500`. If so, return `Math.ceil((size / 500) * innerHeight)`, otherwise return `size`. + +# --hints-- + +Your `proportionalSize` function should have a `return` statement. + +```js +assert.match(proportionalSize.toString(), /return/); +``` + +Your `proportionalSize` function should return a ternary operator that checks if `innerHeight` is less than `500` and returns `Math.ceil((size / 500) * innerHeight)`, otherwise returns `size`. + +```js +assert.match(code, /const\s+proportionalSize\s*=\s*(\(\s*size\s*\)|size)\s*=>\s*{\s*return\s+innerHeight\s*<\s*500\s*\?\s*Math\.ceil\(\s*\(\s*size\s*\/\s*500\s*\)\s*\*\s*innerHeight\s*\)\s*:\s*size\s*;?\s*}\s*/); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                                +

                                                freeCodeCamp Code Warrior

                                                +

                                                + Help the main player navigate to the yellow checkpoints. +

                                                +

                                                + Use the keyboard arrows to move the player around. +

                                                +

                                                You can also use the spacebar to jump.

                                                + +
                                                + +
                                                +
                                                + +
                                                +

                                                Congrats!

                                                +

                                                You reached the last checkpoint.

                                                +
                                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +--fcc-editable-region-- +const proportionalSize = (size) => { + +}; +--fcc-editable-region-- + +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md new file mode 100644 index 00000000000..1bcb82deb8f --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b006efc74c675c2bdfccba.md @@ -0,0 +1,223 @@ +--- +id: 65b006efc74c675c2bdfccba +title: Step 33 +challengeType: 0 +dashedName: step-33 +--- + +# --description-- + +For the last condition, you will need to check if the player's `x` position has exceeded the right edge of the canvas. If it has, you will need to set the player's `x` position to the maximum value so the player does not accidentally go off screen to the right. + +Inside your `update` method, create an `if` statement that checks if `this.position.x >= canvas.width - 2 * this.width`. + +# --hints-- + +You should have an `if` statement inside your `update` method. + +```js +assert.match(code, /if\s*\(\s*.*\s*\)\s*{/g); +``` + +Your `if` statement should check if `this.position.x >= canvas.width - 2 * this.width`. + +```js +assert.match(code, /if\s*\(\s*this\.position\.x\s*>=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width\s*\)\s*{/gi); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                                +

                                                freeCodeCamp Code Warrior

                                                +

                                                + Help the main player navigate to the yellow checkpoints. +

                                                +

                                                + Use the keyboard arrows to move the player around. +

                                                +

                                                You can also use the spacebar to jump.

                                                + +
                                                + +
                                                +
                                                + +
                                                +

                                                Congrats!

                                                +

                                                You reached the last checkpoint.

                                                +
                                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + --fcc-editable-region-- + + --fcc-editable-region-- + } +} +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md new file mode 100644 index 00000000000..8eb13834127 --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b00a6f1c429c5e9fa50e90.md @@ -0,0 +1,219 @@ +--- +id: 65b00a6f1c429c5e9fa50e90 +title: Step 34 +challengeType: 0 +dashedName: step-34 +--- + +# --description-- + +Inside your `if` statement, assign `canvas.width - 2 * this.width` to `this.position.x`. + +This will ensure that the player's `x` position will never exceed the right edge of the canvas. + +# --hints-- + +You should assign `canvas.width - 2 * this.width` to `this.position.x` inside your `if` statement. + +```js +assert.match(code, /this\.position\.x\s*=\s*canvas\.width\s*-\s*2\s*\*\s*this\.width;?/g); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                                +

                                                freeCodeCamp Code Warrior

                                                +

                                                + Help the main player navigate to the yellow checkpoints. +

                                                +

                                                + Use the keyboard arrows to move the player around. +

                                                +

                                                You can also use the spacebar to jump.

                                                + +
                                                + +
                                                +
                                                + +
                                                +

                                                Congrats!

                                                +

                                                You reached the last checkpoint.

                                                +
                                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + --fcc-editable-region-- + + --fcc-editable-region-- + } + } +} +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md new file mode 100644 index 00000000000..4c98c2d86fa --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2a465d7ca3ab6e902285b.md @@ -0,0 +1,388 @@ +--- +id: 65b2a465d7ca3ab6e902285b +title: Step 97 +challengeType: 0 +dashedName: step-97 +--- + +# --description-- + +Below the checkpoint's `width` and `height` properties, use the `this` keyword to add a new `claimed` property and assign it the value of `false`. This property will be used to check if the player has reached the checkpoint. + +# --hints-- + +You should have a `this.claimed` property in the `CheckPoint` class. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert(checkpoint.hasOwnProperty("claimed")); +``` + +You should assign `false` to the `this.claimed` property. + +```js +const checkpoint = new CheckPoint(0, 0, 0); +assert.strictEqual(checkpoint.claimed, false); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                                +

                                                freeCodeCamp Code Warrior

                                                +

                                                + Help the main player navigate to the yellow checkpoints. +

                                                +

                                                + Use the keyboard arrows to move the player around. +

                                                +

                                                You can also use the spacebar to jump.

                                                + +
                                                + +
                                                +
                                                + +
                                                +

                                                Congrats!

                                                +

                                                You reached the last checkpoint.

                                                +
                                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + --fcc-editable-region-- + + --fcc-editable-region-- + }; +}; + + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md new file mode 100644 index 00000000000..3b4224b9bbe --- /dev/null +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-intermediate-oop-by-building-a-platformer-game/65b2bb4c279af3cd585ba777.md @@ -0,0 +1,443 @@ +--- +id: 65b2bb4c279af3cd585ba777 +title: Step 112 +challengeType: 0 +dashedName: step-112 +--- + +# --description-- + +You will need to add two more checkpoint detection rules to the `checkpointDetectionRules` array. + +The first rule should check if the player's `x` position minus the player's `width` is less than or equal to the checkpoint's `x` position minus the checkpoint's `width` plus the player's `width` multiplied by `0.9`. This will ensure that the player is close enough to the checkpoint to claim it. + +The second rule should check if index is strictly equal to `0` or if the previous checkpoint(`checkpoints[index - 1].claimed`) is true. This will ensure that the player can only claim the first checkpoint or a checkpoint that has already been claimed. + +# --hints-- + +You should have a checkpoint detection rule that checks for the following: `player.position.x - player.width <= checkpoint.position.x - checkpoint.width + player.width * 0.9`. + +```js +assert.match(code, /player\.position\.x\s*-\s*player\.width\s*<=\s*checkpoint\.position\.x\s*-\s*checkpoint\.width\s*\+\s*player\.width\s*\*\s*0\.9/i); +``` + +You should have a checkpoint detection rule that checks for the following: `index === 0 || checkpoints[index - 1].claimed === true`. + +```js +assert.match(code, /index\s*===\s*0\s*\|\|\s*checkpoints\[index\s*-\s*1\]\.claimed\s*===\s*true/i); +``` + +# --seed-- + +## --seed-contents-- + +```html + + + + + + + Learn Intermediate OOP by Building a Platformer Game + + + +
                                                +

                                                freeCodeCamp Code Warrior

                                                +

                                                + Help the main player navigate to the yellow checkpoints. +

                                                +

                                                + Use the keyboard arrows to move the player around. +

                                                +

                                                You can also use the spacebar to jump.

                                                + +
                                                + +
                                                +
                                                + +
                                                +

                                                Congrats!

                                                +

                                                You reached the last checkpoint.

                                                +
                                                + + + + + + + +``` + +```css +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +:root { + --main-bg-color: #0a0a23; + --section-bg-color: #ffffff; + --golden-yellow: #feac32; +} + +body { + background-color: var(--main-bg-color); +} + +.start-screen { + background-color: var(--section-bg-color); + width: 100%; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); + border-radius: 30px; + padding: 20px; + padding-bottom: 5px; +} + +.main-title { + text-align: center; +} + +.instructions { + text-align: center; + font-size: 1.2rem; + margin: 15px; + line-height: 2rem; +} + +.btn { + cursor: pointer; + width: 100px; + margin: 10px; + color: #0a0a23; + font-size: 18px; + background-color: var(--golden-yellow); + background-image: linear-gradient(#fecc4c, #ffac33); + border-color: var(--golden-yellow); + border-width: 3px; +} + +.btn:hover { + background-image: linear-gradient(#ffcc4c, #f89808); +} + +.btn-container { + display: flex; + align-items: center; + justify-content: center; +} + +.checkpoint-screen { + position: absolute; + left: 0; + right: 0; + margin-left: auto; + margin-right: auto; + width: 100%; + text-align: center; + background-color: var(--section-bg-color); + border-radius: 20px; + padding: 10px; + display: none; +} + +#canvas { + display: none; +} + +@media (min-width: 768px) { + .start-screen { + width: 60%; + max-width: 700px; + } + + .checkpoint-screen { + max-width: 300px; + } +} + +``` + +```js +const startBtn = document.getElementById("start-btn"); +const canvas = document.getElementById("canvas"); +const startScreen = document.querySelector(".start-screen"); +const checkpointScreen = document.querySelector(".checkpoint-screen"); +const checkpointMessage = document.querySelector(".checkpoint-screen > p"); +const ctx = canvas.getContext("2d"); +canvas.width = innerWidth; +canvas.height = innerHeight; +const gravity = 0.5; +let isCheckpointCollisionDetectionActive = true; + +const proportionalSize = (size) => { + return innerHeight < 500 ? Math.ceil((size / 500) * innerHeight) : size; +} + +class Player { + constructor() { + this.position = { + x: proportionalSize(10), + y: proportionalSize(400), + }; + this.velocity = { + x: 0, + y: 0, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#99c9ff"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + + update() { + this.draw(); + this.position.x += this.velocity.x; + this.position.y += this.velocity.y; + + if (this.position.y + this.height + this.velocity.y <= canvas.height) { + if (this.position.y < 0) { + this.position.y = 0; + this.velocity.y = gravity; + } + this.velocity.y += gravity; + } else { + this.velocity.y = 0; + } + + if (this.position.x < this.width) { + this.position.x = this.width; + } + + if (this.position.x >= canvas.width - 2 * this.width) { + this.position.x = canvas.width - 2 * this.width; + } + } +} + +class Platform { + constructor(x, y) { + this.position = { + x, + y, + }; + this.width = 200; + this.height = proportionalSize(40); + } + draw() { + ctx.fillStyle = "#acd157"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } +} + +class CheckPoint { + constructor(x, y, z) { + this.position = { + x, + y, + }; + this.width = proportionalSize(40); + this.height = proportionalSize(70); + this.claimed = false; + }; + + draw() { + ctx.fillStyle = "#f1be32"; + ctx.fillRect(this.position.x, this.position.y, this.width, this.height); + } + claim() { + this.width = 0; + this.height = 0; + this.position.y = Infinity; + this.claimed = true; + } +}; + +const player = new Player(); + +const platformPositions = [ + { x: 500, y: proportionalSize(450) }, + { x: 700, y: proportionalSize(400) }, + { x: 850, y: proportionalSize(350) }, + { x: 900, y: proportionalSize(350) }, + { x: 1050, y: proportionalSize(150) }, + { x: 2500, y: proportionalSize(450) }, + { x: 2900, y: proportionalSize(400) }, + { x: 3150, y: proportionalSize(350) }, + { x: 3900, y: proportionalSize(450) }, + { x: 4200, y: proportionalSize(400) }, + { x: 4400, y: proportionalSize(200) }, + { x: 4700, y: proportionalSize(150) }, +]; + +const platforms = platformPositions.map( + (platform) => new Platform(platform.x, platform.y) +); + +const checkpointPositions = [ + { x: 1170, y: proportionalSize(80), z: 1 }, + { x: 2900, y: proportionalSize(330), z: 2 }, + { x: 4800, y: proportionalSize(80), z: 3 }, +]; + +const checkpoints = checkpointPositions.map( + (checkpoint) => new CheckPoint(checkpoint.x, checkpoint.y, checkpoint.z) +); + +const animate = () => { + requestAnimationFrame(animate); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + platforms.forEach((platform) => { + platform.draw(); + }); + + checkpoints.forEach(checkpoint => { + checkpoint.draw(); + }); + + player.update(); + + if (keys.rightKey.pressed && player.position.x < proportionalSize(400)) { + player.velocity.x = 5; + } else if (keys.leftKey.pressed && player.position.x > proportionalSize(100)) { + player.velocity.x = -5; + } else { + player.velocity.x = 0; + + if (keys.rightKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x -= 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x -= 5; + }); + + } else if (keys.leftKey.pressed && isCheckpointCollisionDetectionActive) { + platforms.forEach((platform) => { + platform.position.x += 5; + }); + + checkpoints.forEach((checkpoint) => { + checkpoint.position.x += 5; + }); + } + } + + platforms.forEach((platform) => { + const collisionDetectionRules = [ + player.position.y + player.height <= platform.position.y, + player.position.y + player.height + player.velocity.y >= platform.position.y, + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + ]; + + if (collisionDetectionRules.every((rule) => rule)) { + player.velocity.y = 0; + return; + } + + const platformDetectionRules = [ + player.position.x >= platform.position.x - player.width / 2, + player.position.x <= + platform.position.x + platform.width - player.width / 3, + player.position.y + player.height >= platform.position.y, + player.position.y <= platform.position.y + platform.height, + ]; + + if (platformDetectionRules.every(rule => rule)) { + player.position.y = platform.position.y + player.height; + player.velocity.y = gravity; + }; + }); + + + checkpoints.forEach((checkpoint, index, checkpoints) => { + const checkpointDetectionRules = [ + player.position.x >= checkpoint.position.x, + player.position.y >= checkpoint.position.y, + player.position.y + player.height <= + checkpoint.position.y + checkpoint.height, + isCheckpointCollisionDetectionActive + --fcc-editable-region-- + + --fcc-editable-region-- + ]; + }); + +} + + +const keys = { + rightKey: { + pressed: false + }, + leftKey: { + pressed: false + } +}; + +const movePlayer = (key, xVelocity, isPressed) => { + if (!isCheckpointCollisionDetectionActive) { + player.velocity.x = 0; + player.velocity.y = 0; + return; + } + + switch (key) { + case "ArrowLeft": + keys.leftKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x -= xVelocity; + break; + case "ArrowUp": + case " ": + case "Spacebar": + player.velocity.y -= 8; + break; + case "ArrowRight": + keys.rightKey.pressed = isPressed; + if (xVelocity === 0) { + player.velocity.x = xVelocity; + } + player.velocity.x += xVelocity; + } +} + +const startGame = () => { + canvas.style.display = "block"; + startScreen.style.display = "none"; + animate(); +} + +const showCheckpointScreen = (msg) => { + checkpointScreen.style.display = "block"; + checkpointMessage.textContent = msg; + if (isCheckpointCollisionDetectionActive) { + setTimeout(() => (checkpointScreen.style.display = "none"), 2000); + } +}; + +startBtn.addEventListener("click", startGame); + +window.addEventListener("keydown", ({ key }) => { + movePlayer(key, 8, true); +}); + +window.addEventListener("keyup", ({ key }) => { + movePlayer(key, 0, false); +}); + +``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md index 278a2ba77ae..ca30e99cfa6 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e4c4ec263b62ae7bf54d.md @@ -18,37 +18,37 @@ Begin by accessing the `task-form`, `confirm-close-dialog`, and `open-task-form- Використайте `getElementById()`, щоб отримати доступ до елемента `task-form`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` You should assign the `task-form` element to the variable `taskForm`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\);?/) +assert.match(code, /const\s+taskForm\s*=\s*document\.getElementById\(\s*('|"|`)task\-form\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `confirm-close-dialog`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` You should assign the `confirm-close-dialog` element to the variable `confirmCloseDialog`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\);?/) +assert.match(code, /const\s+confirmCloseDialog\s*=\s*document\.getElementById\(\s*('|"|`)confirm\-close\-dialog\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `open-task-form-btn`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `open-task-form-btn` element to the variable `openTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+openTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)open\-task\-form\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md index 32c795f5885..d9815e3fdd8 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6c86954de67a3e44ee3.md @@ -14,37 +14,37 @@ You need to access more elements with the `getElementById()` method. This time y Використайте `getElementById()`, щоб отримати доступ до елемента `close-task-form-btn`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` You should assign the `close-task-form-btn` element to the variable `closeTaskFormBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\);?/) +assert.match(code, /const\s+closeTaskFormBtn\s*=\s*document\.getElementById\(\s*('|"|`)close\-task\-form\-btn\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `add-or-update-task-btn`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` You should assign the `add-or-update-task-btn` element to the variable `addOrUpdateTaskBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\);?/) +assert.match(code, /const\s+addOrUpdateTaskBtn\s*=\s*document\.getElementById\(\s*('|"|`)add\-or\-update\-task\-btn\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `cancel-btn`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` You should assign the `cancel-btn` element to the variable `cancelBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\);?/) +assert.match(code, /const\s+cancelBtn\s*=\s*document\.getElementById\(\s*('|"|`)cancel\-btn\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md index 5bac8a11981..cc9a4faa013 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e6fe78b5aa67ef2fc3e7.md @@ -14,37 +14,37 @@ Next, access the `discard-btn`, `tasks-container`, and `title-input` elements us Використайте `getElementById()`, щоб отримати доступ до елемента `discard-btn`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` You should assign the `discard-btn` element to the variable `discardBtn`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\);?/) +assert.match(code, /const\s+discardBtn\s*=\s*document\.getElementById\(\s*('|"|`)discard\-btn\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `tasks-container`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` You should assign the `tasks-container` element to the variable `tasksContainer`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\);?/) +assert.match(code, /const\s+tasksContainer\s*=\s*document\.getElementById\(\s*('|"|`)tasks\-container\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `title-input`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` You should assign the `title-input` element to the variable `titleInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\);?/) +assert.match(code, /const\s+titleInput\s*=\s*document\.getElementById\(\s*('|"|`)title\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md index a3fb63923de..38e7b99d3c6 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4e7241f52bb682eeb8211.md @@ -14,25 +14,25 @@ The last set of elements you need to get from the HTML file are the `date-input` Використайте `getElementById()`, щоб отримати доступ до елемента `date-input`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` You should assign the `date-input` element to the variable `dateInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\);?/) +assert.match(code, /const\s+dateInput\s*=\s*document\.getElementById\(\s*('|"|`)date\-input\1\s*\)\s*;?/) ``` Використайте `getElementById()`, щоб отримати доступ до елемента `description-input`. ```js -assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` You should assign the `description-input` element to the variable `descriptionInput`. Don't forget to use `const` to declare the variable. ```js -assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\);?/) +assert.match(code, /const\s+descriptionInput\s*=\s*document\.getElementById\(\s*('|"|`)description\-input\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md index 046e66a74d9..56ea7f866fb 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ebc7eabc5a6babd479cd.md @@ -34,13 +34,13 @@ assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\ Your event listener should use the `close()` method on `confirmCloseDialog`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?/) ``` Your event listener should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\);?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\);?\s*\}\s*\);?/) +assert.match(code, /discardBtn\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*confirmCloseDialog\.close\(\s*\)\s*;?\s*taskForm\.classList\.toggle\(\s*('|"|`)hidden\2\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md index 55ddc9d3a9e..18b3b5ce4fe 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4ecd7735a566c9266a338.md @@ -34,7 +34,7 @@ assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e You should use the `e.preventDefault()` method to stop the browser from reloading the page. ```js -assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\);?/) +assert.match(code, /taskForm\.addEventListener\(\s*('|"|`)submit\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*\{\s*e\.preventDefault\(\s*\)\s*;?\s*\}\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md index 3812b481276..4d03652a698 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64e4eec13546c06d61a63d59.md @@ -41,7 +41,7 @@ assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*ite Your arrow function callback should check if `item.id === currentTask.id`. ```js -assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\);?/) +assert.match(code, /const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*item\.id\s*===\s*currentTask\.id\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md index 7f4032bbced..9d596ca04fd 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec8f717b261e824d82d6a5.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{/) Your `if` statement should have `taskData.unshift(taskObj)` in it's body. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}/) ``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md index b1de00ff944..6696b24e068 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec9282cd547785258cecf2.md @@ -26,7 +26,7 @@ assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*(\s*\{?\(\s*ta You should use addition assignment to set the `innerHTML` of `tasksContainer` to an empty pair of backticks. ```js -assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\s*\(?tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)?\s*\}?)/) +assert.match(code, /taskData\.forEach\(\s*\(\s*\{.*\}\s*\)\s*=>\s*\{?\s*(\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*`\s*\)|tasksContainer\.innerHTML\s*\+=\s*`\s*`)\s*\}?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md index 3946cedfcc8..6c57a5cf522 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec94f0de20c086e09b0fc3.md @@ -7,7 +7,7 @@ dashedName: step-19 # --description-- -Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `Title:`. +Create a `p` element and use template strings to set its content to the `title` you destructured. Right before the content of the `p` element, create a `strong` element with the text `"Title:"`. # --hints-- @@ -29,7 +29,7 @@ You should create a `strong` element after the opening tag of your `p` element. assert.match(code, /

                                                /) ``` -Your `strong` element should have the text `Title:`. +Your `strong` element should have the text `"Title:"`. ```js assert.match(code, /

                                                Title:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md index 54accc4d07c..e9b3e0d6a9f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec959a76336c8767f5cd4d.md @@ -7,7 +7,7 @@ dashedName: step-20 # --description-- -Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `Date:`. +Similarly to the previous step, create another `p` element, and interpolate the `date` you destructured as the text content. Inside this paragraph, create a `strong` element with the text `"Date:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element and interpolate `${date}` as the text. assert.match(code, /

                                                .*\$\{date\}<\/p>/) ``` -You should create a `strong` element with the text `Date:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Date:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                                Date:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md index 75c7000dda3..c868a7cfc18 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ec96761156a187ed32b274.md @@ -9,17 +9,17 @@ dashedName: step-22 To allow for task management, you need to include both a delete and an edit button for each task. -Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `Edit` and the text of the second button to `Delete`. +Create two `button` elements with the `type` attribute set to `button` and the `class` attribute set to `btn`. Set the text of the first button to `"Edit"` and the text of the second button to `"Delete"`. # --hints-- -You should create a `button` element of type `button`, a class `btn` and `Edit` as the text, in that order. +You should create a `button` element of type `button`, a class `btn` and `"Edit"` as the text, in that order. ```js assert.match(code, /Edit<\/button/) ``` -You should create a `button` element of type `button` a class `btn` and `Delete` as the text, in that order. +You should create a `button` element of type `button` a class `btn` and `"Delete"` as the text, in that order. ```js assert.match(code, /Delete<\/button/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md index a8c346c2d9a..6378c73114f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac365aeb8ad70b69b366f.md @@ -16,19 +16,19 @@ Also, use `classList` to toggle the class `hidden` on the `taskForm` and set `cu You should set `titleInput.value` to an empty string. ```js -assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /titleInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `dateInput.value` to an empty string. ```js -assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /dateInput\.value\s*=\s*('|")\1\s*;?/) ``` You should set `descriptionInput.value` to an empty string. ```js -assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1;?/) +assert.match(reset.toString(), /descriptionInput\.value\s*=\s*('|")\1\s*;?/) ``` You should use `classList` to toggle the class `hidden` on `taskForm` @@ -40,7 +40,7 @@ assert.match(reset.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s* You should set `currentTask` to an empty object. ```js -assert.match(reset.toString(), /currentTask\s*=\s*\{\};?/) +assert.match(reset.toString(), /currentTask\s*=\s*\{\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md index 389ad51e691..f21af322283 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac4d1773e7a719b1254de.md @@ -15,7 +15,7 @@ You should remove the code toggling the `hidden` class on `taskForm`. ```js const splitter = code.split('') -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md index a7e09228e1c..ccd6c0d09e2 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fac6a497811572b338e5e5.md @@ -15,13 +15,13 @@ You should remove the code toggling the class `hidden` on `taskForm`. ```js const splitter = code.split("confirmCloseDialog.close();") -assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\);?/) +assert.notMatch(splitter[1], /taskForm\.classList\.toggle\(\s*("|')hidden\1\s*\)\s*;?/) ``` You should call the `reset` function. ```js -assert.match(code, /confirmCloseDialog\.close\(\s*\);?\s*reset\(\s*\);?/) +assert.match(code, /confirmCloseDialog\.close\(\s*\)\s*;?\s*reset\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md index f7ae30ef660..36732dbdccf 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faca774fd9fd74bc084cc9.md @@ -16,7 +16,7 @@ To begin, within the `closeTaskFormBtn` event listener, create a `formInputsCont You should use `const` to create a variable `formInputsContainValues` with the value `titleInput.value || dateInput.value || descriptionInput.value;` ```js -assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\;?/) +assert.match(code, /const\s+formInputsContainValues\s*=\s*(titleInput\.value\s*\|\|\s*dateInput\.value\s*\|\|\s*descriptionInput\.value|titleInput\.value\s*!==\s*null\s*\|\|\s*dateInput\.value\s*!==\s*null\s*\|\|\s*descriptionInput\.value\s*!==\s*null)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md index 7765f732128..6a3e880ea9c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64facf6180824876f70a2e86.md @@ -20,19 +20,19 @@ assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{/) The `if` block of your `if` statement should contain `confirmCloseDialog.showModal();`. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?/) ``` Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{/) ``` You should call the `reset()` function in the `else` block of your `if` statement. ```js -assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\);?\s*\}\s*else\s*\{\s*reset\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*formInputsContainValues\s*\)\s*\{\s*confirmCloseDialog\.showModal\(\s*\)\s*;?\s*\}\s*else\s*\{\s*reset\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md index af677332cb1..3752741d1aa 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad07f43a101779cb8692a.md @@ -22,7 +22,7 @@ assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*/) You should move the `dataArrIndex` variable into the `addOrUpdateTask` function. ```js -assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\);?/) +assert.match(code, /const\s+addOrUpdateTask\s*=\s*\(\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*currentTask\.id|currentTask\.id\s*===\s*item\.id)\s*\)\s*;?/) ``` You should move the `taskObj` object into the `addOrUpdateTask` function. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md index c3627a53dc2..793d9884492 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fad9cd2eeb1e7ca2ca8c8b.md @@ -20,7 +20,7 @@ assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{/) You should move `taskData.forEach()` and its content into the `updateTaskContainer()` function. ```js -assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                                Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                                Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                                Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\);?\s*\};?/) +assert.match(code, /const\s+updateTaskContainer\s*=\s*\(\s*\)\s*=>\s*\{\s*taskData\.forEach\(\s*\(\s*\{\s*id\s*,\s*title\s*,\s*date\s*,\s*description\s*\}\s*\)\s*=>\s*{\s*\(\s*tasksContainer\.innerHTML\s*\+=\s*`\s*\s*

                                                Title:<\/strong>\s*\$\{title\}<\/p>\s*

                                                Date:<\/strong>\s*\$\{date\}<\/p>\s*

                                                Description:<\/strong>\s*\$\{description\}<\/p>\s*Edit<\/button>\s*Delete<\/button>\s*<\/div>\s*`\s*\)\s*}\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md index 696192c8836..2e825af7800 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fadae4f2d51b7d5d8b98d8.md @@ -20,7 +20,7 @@ assert.match(code, /updateTaskContainer\(\s*\)\s*/) You should call the `reset` function after calling the `updateTaskContainer` function. ```js -assert.match(code, /updateTaskContainer\(\s*\);?\s*reset\(\s*\);?\s*/) +assert.match(code, /updateTaskContainer\(\s*\)\s*;?\s*reset\(\s*\)\s*;?\s*/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md index e5f7b9af5ec..b9bc6e6bb30 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf0418e828c0114a558a7.md @@ -17,7 +17,7 @@ Set the `innerHTML` of `tasksContainer` back to an empty string. You should set the `innerHTML` of `tasksContainer` to an empty string. ```js -assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1;?/) +assert.match(code, /tasksContainer\.innerHTML\s*=\s*("|')\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md index 567e902b528..161f274bf74 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf65b22ad8d07df9be14d.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*cons Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. Don't use curly braces. ```js -assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+deleteTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md index 2d3b03098b8..94e5b3d9320 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64faf874364ec308f875f636.md @@ -30,7 +30,7 @@ Use the `remove()` method to remove the `parentElement` of the `buttonEl` from t You should use the `remove()` method to remove the parent element of `buttonEl`. ```js -assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\);?/) +assert.match(deleteTask.toString(), /buttonEl\.parentElement\.remove\(\s*\)\s*;?/) ``` You should use `splice()` on the `taskData` array. @@ -48,7 +48,7 @@ assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex/) The second argument of your `splice()` method should be `1`. ```js -assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\);?/) +assert.match(deleteTask.toString(), /taskData\.splice\(\s*dataArrIndex\s*,\s*1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md index f794a80c814..acd900996e1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb0fa0968f2b113b2d90e9.md @@ -34,7 +34,7 @@ assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\ Your arrow function callback should check if `item.id === buttonEl.parentElement.id`. ```js -assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\);?\s*\};?/) +assert.match(code, /const\s+editTask\s*=\s*\(\s*buttonEl\s*\)\s*=>\s*\{\s*const\s+dataArrIndex\s*=\s*taskData\.findIndex\(\s*(\(\s*item\s*\)|item)\s*=>\s*(item\.id\s*===\s*buttonEl\.parentElement\.id|buttonEl\.parentElement\.id\s*===\s*item\.id)\s*\)\s*;?\s*\}\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md index 646fdbc4eb4..37ed21ba5b5 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1321e189a6136d200f77.md @@ -14,19 +14,19 @@ The task to be edited is now in the `currentTask` object. Stage it for editing i You should set `titleInput.value` to `currentTask.title`. ```js -assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title;?/) +assert.match(editTask.toString(), /titleInput\.value\s*=\s*currentTask\.title\s*;?/) ``` You should set `dateInput.value` to `currentTask.date`. ```js -assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date;?/) +assert.match(editTask.toString(), /dateInput\.value\s*=\s*currentTask\.date\s*;?/) ``` You should set `descriptionInput.value` to `currentTask.description`. ```js -assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description;?/) +assert.match(editTask.toString(), /descriptionInput\.value\s*=\s*currentTask\.description\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md index ecee9d24283..50fdddc92bf 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1436adef3e145b4c3501.md @@ -14,7 +14,7 @@ Set the `innerText` of the `addOrUpdateTaskBtn` button to `Update Task`. You should set the inner text of the `addOrUpdateTaskBtn` button to `Update Task` ```js -assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1;?/) +assert.match(editTask.toString(), /addOrUpdateTaskBtn\.innerText\s*=\s*("|')Update Task\1\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md index ca502f2715e..d557e156c88 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb14d890415c14f93069ce.md @@ -14,7 +14,7 @@ Finally, display the `form` modal with the values of the input fields by using ` You should use `classList` to toggle the class `hidden` on `taskForm`. ```js -assert.match(editTask.toString(), /taskForm\.classList\.toggle\(('|")hidden\1\);?/) +assert.match(editTask.toString(), /taskForm\.classList\.toggle\(\s*('|")hidden\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md index 5daff8094d9..7b32a4011b3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb154a7c48cd159924bb18.md @@ -14,13 +14,13 @@ At this point, editing a task won't reflect when you submit the task. To make th Your `if` statement should have an `else` block. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*/) ``` Your `else` block should have the code `taskData[dataArrIndex] = taskObj`. ```js -assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\);?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj;?\s*\}/) +assert.match(code, /if\s*\(\s*dataArrIndex\s*===\s*-1\s*\)\s*\{\s*taskData\.unshift\(\s*taskObj\s*\)\s*;?\s*\}\s*else\s*\{\s*taskData\s*\[\s*dataArrIndex\s*\]\s*=\s*taskObj\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md index 8e7876cbc89..25c7ec09ba1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb1c4dc0feb219149a7c7d.md @@ -16,19 +16,26 @@ Inside the `closeTaskFormBtn` event listener, use `const` to create another vari Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)/ + +assert.match(code, regex) ``` Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title` or `dateInput.value` is not equal to `currentTask.date`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date/) +const regex = /const\s+formInputValuesUpdated\s*=(?=.*titleInput\.value\s*(!==|!=)\s*currentTask\.title)(?=.*dateInput\.value\s*(?:!==|!=)\s*currentTask\.date)/ + +assert.match(code, regex); + ``` -Your `formInputValuesUpdated` variable should have the value `titleInput.value !== currentTask.title || dateInput.value !== currentTask.date || descriptionInput.value !== currentTask.description`. +Your `formInputValuesUpdated` variable should check if `titleInput.value` is not equal to `currentTask.title`, `dateInput.value` is not equal to `currentTask.date`, or `descriptionInput.value` is not equal to `currentTask.description`. ```js -assert.match(code, /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description;?/) +const regex = /const\s+formInputValuesUpdated\s*=\s*titleInput\.value\s*!==\s*currentTask\.title\s*\|\|\s*dateInput\.value\s*!==\s*currentTask\.date\s*\|\|\s*descriptionInput\.value\s*!==\s*currentTask\.description\s*;?/ + +assert.match(code, regex); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md index 8f1be619013..51cfb4c727b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fb29348a60361ccd45c1e2.md @@ -32,7 +32,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) Your `localStorage.setItem()` should have a value of `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*myTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md index d242c0e48db..e5a12d418d1 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64fefebad99209211ec30537.md @@ -22,7 +22,7 @@ assert.match(code, /localStorage\.setItem\(\s*("|')data\1/) You should wrap `JSON.stringify()` around `myTaskArr`. ```js -assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*("|')data\1\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md index f782e71d51a..2a42d673edc 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff0313700dad264d19dfe4.md @@ -16,13 +16,13 @@ Use the `getItem()` method to retrieve the `myTaskArr` array and assign it to th You should use `const` to create a `getTaskArr` variable and assign `localStorage.getItem("data")` to it. ```js -assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should log the `getTaskArr` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArr\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArr\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md index 2ea63a26f14..2b1bf75889e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff04cc33779427a6412449.md @@ -18,13 +18,13 @@ Check the console to see the difference between `getTaskArr` and `getTaskObj`. You should use `const` to create a `getTaskArrObj` variable and assign it to `JSON.parse(localStorage.getItem('data'));`. ```js -assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\);?/) +assert.match(code, /const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\1\s*\)\s*\)\s*;?/) ``` You should log the `getTaskArrObj` variable to the console. ```js -assert.match(code, /console\.log\(\s*getTaskArrObj\s*\);?/) +assert.match(code, /console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md index cdd392bb55a..78c5f7fd965 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff068e0426eb288874ed79.md @@ -16,7 +16,7 @@ Remove the `data` item from local storage and open the console to observe the re You should use `localStorage.removeItem()` to remove the `data` item from the browser's local storage. ```js -assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);?/) +assert.match(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md index ac926b255e9..d402ed286da 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff23daf176a92de95f24dc.md @@ -16,13 +16,13 @@ Remove `localStorage.removeItem()` and use `localStorage.clear()` instead. You d You should remove `localStorage.removeItem("data")`. ```js -assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\);/) +assert.notMatch(code, /localStorage\.removeItem\(\s*('|")data\1\s*\)\s*;?/) ``` You should remove everything from the browser `local storage` with `localStorage.clear()`. ```js -assert.match(code, /localStorage\.clear\(\s*\);?/) +assert.match(code, /localStorage\.clear\(\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md index 64d936fafcf..5f9aec4f3a7 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/64ff24b80431f62ec6b93f65.md @@ -14,7 +14,7 @@ Remove the `myTaskArr` array and all of the code for `localStorage` because you You should remove `myTaskArr` and all the code related to `localStorage` that you've just learned. ```js -assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\);\s*localStorage\.clear\(\s*\);?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\);?\s*console\.log\(\s*getTaskArrObj\s*\);?/) +assert.notMatch(code, /const\s+myTaskArr\s*=\s*\[\s*\{\s*task:\s('|")Walk\s*the\s*Dog\1\s*,\s*date:\s*('|")22-04-2022\2\s*\}\s*,\s*\{\s*task:\s('|")Read\s*some\s*books\3\s*,\s*date:\s*('|")02-11-2023\4\s*\}\s*,\s*\{\s*task:\s('|")Watch\s*football\5\s*,\s*date:\s*('|")10-08-2021\6\s*\}\s*,\s*\]\s*;?\s*localStorage\.setItem\(('|")data\7\s*,\s*JSON\.stringify\(\s*myTaskArr\s*\)\s*\)\s*;?\s*localStorage\.clear\(\s*\)\s*;?\s*const\s+getTaskArr\s*=\s*localStorage\.getItem\(\s*('|")data\8\s*\)\s*console\.log\(\s*getTaskArr\s*\)\s*const\s+getTaskArrObj\s*=\s*JSON\.parse\(\s*localStorage\.getItem\(\s*('|")data\9\s*\)\s*\)\s*;?\s*console\.log\(\s*getTaskArrObj\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md index 8e96339ab99..6873f76ad26 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65003986d17d1e1865b269c0.md @@ -30,7 +30,7 @@ assert.match(code, /localStorage\.setItem\(\s*('|")data\1/) You should pass in `JSON.stringify(taskData)` as the second argument of your `localStorage.setItem()`. ```js -assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(code, /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md index 93bdb20643a..b5aac7726b6 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/650046832f92c01a35834bca.md @@ -31,7 +31,7 @@ You should pass in `JSON.stringify(taskData)` as the second argument of your `lo ```js const splitter = code.split("taskData.splice(dataArrIndex, 1);") -assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\);?/) +assert.match(splitter[1], /localStorage\.setItem\(\s*('|")data\1\s*,\s*JSON\.stringify\(\s*taskData\s*\)\s*\)\s*;?/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md index 3412d755935..85ab94fb0f3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65004ba581d03d1d5628b41c.md @@ -26,7 +26,7 @@ assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*/) You should call the `updateTaskContainer` function in your `if` statement. ```js -assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\);?\s*\}/) +assert.match(code, /if\s*\(\s*taskData\.length\s*\)\s*\{\s*updateTaskContainer\(\s*\)\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md index 9a6242ed6f2..39d676506f3 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/65099dbd8f137d58e5c0ff16.md @@ -7,7 +7,7 @@ dashedName: step-21 # --description-- -Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `Description:`. +Create one more `p` element and interpolate the `description` you destructured as the text. Also, create a `strong` element inside the paragraph with the text `"Description:"`. # --hints-- @@ -17,7 +17,7 @@ You should create a `p` element with `${description}` as the text. assert.match(code, /

                                                .*\$\{description\}<\/p>/) ``` -You should create a `strong` element with the text `Description:` after the opening tag of your `p` element. +You should create a `strong` element with the text `"Description:"` after the opening tag of your `p` element. ```js assert.match(code, /

                                                Description:\s*<\/strong>\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md index bba3343cf51..8b5a59c715e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-localstorage-by-building-a-todo-app/659ebe52d74b132a1d75c891.md @@ -9,10 +9,10 @@ dashedName: step-46 If you try to add a new task, edit that task, and then click on the `Add New Task` button, you will notice a bug. -The form button will display the incorrect text of `Update Task` instead of `Add Task`. To fix this, you will need to assign the string `Add Task` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. +The form button will display the incorrect text of `"Update Task"` instead of `"Add Task"`. To fix this, you will need to assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText` inside your `addOrUpdateTask` function. # --hints-- -You should assign the string `Add Task` to `addOrUpdateTaskBtn.innerText`. +You should assign the string `"Add Task"` to `addOrUpdateTaskBtn.innerText`. ```js assert.match(code, /addOrUpdateTaskBtn\.innerText\s*=\s*('|")Add Task\1\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md index 94a42909f96..bf11251ffac 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63c620161fc2b49ac340ffc4.md @@ -9,7 +9,7 @@ dashedName: step-1 In this project, you will build a set of football team cards and learn about nested objects, object destructuring, default parameters, event listeners, and switch statements. Вам надано HTML та CSS для цього проєкту. -Start by accessing the `id` called `team` from the HTML document and storing it in a `const` variable called `teamName`. +Start by accessing the `id` called `"team"` from the HTML document and storing it in a `const` variable called `teamName`. Remember, you can use the `getElementById` method for this. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md index 409701f9298..fb0b298e529 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7e324c1831f8d936b3ae.md @@ -7,7 +7,7 @@ dashedName: step-2 # --description-- -Next, access the `id` called `sport` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `year` to a `const` variable called `worldCupYear`. +Next, access the `id` called `"sport"` from the HTML document and store it in a `const` variable called `typeOfSport`. Below that variable, assign the `id` of `"year"` to a `const` variable called `worldCupYear`. # --hints-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md index 2775a79b4ba..00a8ac58fee 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf7f97e7f99af9348f5068.md @@ -7,7 +7,7 @@ dashedName: step-3 # --description-- -Next, access the `id` called `head-coach` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `player-cards` to a `const` variable called `playerCards`. +Next, access the `id` called `"head-coach"` from the HTML document and store it in a `const` variable called `headCoach`. Below that variable, assign the `id` of `"player-cards"` to a `const` variable called `playerCards`. # --hints-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md index 134cbde972b..10f638105d9 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf812bb8ecd4f9cf749b8f.md @@ -7,7 +7,7 @@ dashedName: step-4 # --description-- -Create one more `const` variable called `playersDropdownList` and assign it the `id` of `players` using the `getElementById` method. +Create one more `const` variable called `playersDropdownList` and assign it the `id` of `"players"` using the `getElementById` method. # --hints-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md index 1f1509b1471..3be19b48d98 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf8ec006a776ff5f6e3c68.md @@ -7,7 +7,7 @@ dashedName: step-6 # --description-- -Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `Argentina`. +Inside the `myFavoriteFootballTeam` object, add a new property with a key named `team` and a string value of `"Argentina"`. # --hints-- @@ -18,7 +18,7 @@ Your `myFavoriteFootballTeam` object should have a `team` property. assert.property(myFavoriteFootballTeam, 'team'); ``` -Your `team` property should be set to `Argentina`. +Your `team` property should be set to `"Argentina"`. ```js assert.equal(myFavoriteFootballTeam.team, 'Argentina'); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md index 80fb875d433..d24fc3c8526 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf90d4696d8f00851873a4.md @@ -7,7 +7,7 @@ dashedName: step-7 # --description-- -Below the `team` property, add a new property with a key named `sport` and a string value of `Football`. +Below the `team` property, add a new property with a key named `sport` and a string value of `"Football"`. # --hints-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md index 017afbb1508..aae2f2ebf2b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63cf93472de77d01bf8474bf.md @@ -7,7 +7,7 @@ dashedName: step-10 # --description-- -Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `Carlos Bilardo`. Below that property, add another key called `matches` with a number value of 7. +Below the `isWorldCupWinner` property, add a new key called `headCoach` with a value of an empty object. Inside that object, add a property with a key of `coachName` and a string value of `"Carlos Bilardo"`. Below that property, add another key called `matches` with a number value of `7`. # --hints-- @@ -29,7 +29,7 @@ Your `headCoach` object should have a `coachName` property. assert.property(myFavoriteFootballTeam.headCoach, 'coachName'); ``` -Your `coachName` property should be set to `Carlos Bilardo`. +Your `coachName` property should be set to `"Carlos Bilardo"`. ```js assert.equal(myFavoriteFootballTeam.headCoach.coachName, 'Carlos Bilardo'); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md index 7bb1dde201a..2c8dd6ed136 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d1214a0ac7a9389793269b.md @@ -31,7 +31,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[0], 'name'); ``` -Your `name` property should be set to `Sergio Almirón`. +Your `name` property should be set to `"Sergio Almirón"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.name, 'Sergio Almirón'); @@ -43,7 +43,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[0], 'position'); ``` -Your `position` property should be set to `forward`. +Your `position` property should be set to `"forward"`. ```js assert.equal(myFavoriteFootballTeam.players[0]?.position, 'forward'); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md index be571cd18db..36cc2b3ca42 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63d128eaedcc773d2ded2128.md @@ -38,7 +38,7 @@ Your new object should have a `name` property. assert.property(myFavoriteFootballTeam.players[1], 'name'); ``` -Your `name` property should be set to `Sergio Batista`. +Your `name` property should be set to `"Sergio Batista"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.name, 'Sergio Batista'); @@ -50,7 +50,7 @@ Your new object should have a `position` property. assert.property(myFavoriteFootballTeam.players[1], 'position'); ``` -Your `position` property should be set to `midfielder`. +Your `position` property should be set to `"midfielder"`. ```js assert.equal(myFavoriteFootballTeam.players[1]?.position, 'midfielder'); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md index f1e07afb21f..d384721b764 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e949b8327aa2aca2ca8eac.md @@ -36,7 +36,7 @@ assert.match(setPlayerCards.toString(), /playerCards\.innerHTML\s*\+=/); You should assign `arr.map()` to the `playerCards.innerHTML` using the `+=` operator. ```js -assert.match(code, /playerCards\.innerHTML\s+\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) +assert.match(code, /playerCards\.innerHTML\s*\+=\s*arr\.map\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md index 3dffd3b6e71..a1d687bb13e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e954321b0a77ae4f6d9650.md @@ -9,11 +9,11 @@ dashedName: step-27 Inside the body of the callback function, you will need to add template literals ` `` ` which will contain the HTML content for the player cards. -Inside the template literals, add an empty `div` with a class of `player-card`. +Inside the template literals, add an empty `div` with a class of `"player-card"`. # --hints-- -You should use template literals to add an empty `div` with a class of `player-card`. +You should use template literals to add an empty `div` with a class of `"player-card"`. ```js diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md index 798565f8402..6e4bf69791b 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e95e39860dc5b01ebe9be0.md @@ -9,11 +9,11 @@ dashedName: step-29 Наступним кроком буде показ слова `(Captain)` біля гравця, якщо він вказаний як капітан команди. -Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `(Captain)` otherwise return an empty string. +Right next to the `${name}` expression, add a new embedded expression. Inside that expression, use a ternary operator to check if `isCaptain` is true. If so, return `"(Captain)"` otherwise return an empty string. # --hints-- -You should use a ternary operator to check if `isCaptain` is true and return `(Captain)` or return an empty string. +You should use a ternary operator to check if `isCaptain` is true and return `"(Captain)"` or return an empty string. ```js assert.match(code, /\s*\s*\${\s*name\s*}\s*\$\{isCaptain(\s*===\s*true)?\s*\?\s*('|"|`)\(Captain\)\2\s*:\s*('|"|`)\3\}\s*<\/h2>\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md index 4d7f1f20f32..efd4b210e85 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63e9718d7d490bb3940d5a0a.md @@ -25,7 +25,7 @@ If your ternary is truthy, it should display the player's `nickname`. assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:/) ``` -If your ternary is falsy, it should display the string `N/A`. +If your ternary is falsy, it should display the string `"N/A"`. ```js assert.match(code, /\s*\s*Nickname:\s*\$\{\s*nickname\s*(?:!==\s*null)?\s*\?\s*nickname\s*:\s*('|"|`)\N\/A\1\s*\}\s*<\/p>\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md index e10980a7652..6891eca7b0f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f28972973504e7bb58b0b3.md @@ -9,7 +9,7 @@ dashedName: step-35 The next step is to create a function that will detect when a user makes a selection from the `playersDropdownList`. -Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `change` event type and an empty callback function. +Use the `.addEventListener()` method on `playersDropdownList`. Inside the event listener, pass in a `"change"` event type and an empty callback function. # --hints-- @@ -19,7 +19,7 @@ You should call the `.addEventListener()` method on the `playersDropdownList` va assert.match(code, /playersDropdownList\.addEventListener\(/); ``` -Your event listener should listen for the `change` event. +Your event listener should listen for the `"change"` event. ```js assert.match(code, /playersDropdownList\.addEventListener\(\s*('|"|`)change\1/); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md index 6c469003ad5..fa190518530 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a0a860790eebe61bf908.md @@ -9,11 +9,11 @@ dashedName: step-40 If the user selects `Nicknames` from the dropdown menu you will want to filter out player cards that have a nickname. -Start by adding a `case` clause for `nickname` inside your `switch` statement. +Start by adding a `case` clause for `"nickname"` inside your `switch` statement. # --hints-- -You should add a new `case` clause for `nickname` inside your `switch` statement. +You should add a new `case` clause for `"nickname"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*/) diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md index d131760c8c5..b3722350923 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a4a8087e6dec8ec47f16.md @@ -7,23 +7,23 @@ dashedName: step-43 # --description-- -Next, add a `case` clause for `forward`. +Next, add a `case` clause for `"forward"`. Inside that `case`, call the `setPlayerCards` function with an argument of `players.filter()`. -Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `forward`. +Inside the `filter()` method, add a callback function with a parameter of `player` that will check if `player.position` equals `"forward"`. Lastly, add a `break` statement below the `setPlayerCards` function call. # --hints-- -You should add a new `case` for `forward` inside your `switch` statement. +You should add a new `case` for `"forward"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*/) ``` -In your `forward` `case`, you should call the `setPlayerCards` function. +In your `"forward"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(/) @@ -47,7 +47,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `forward`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"forward"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)/) @@ -56,7 +56,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*pl You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*forward\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(?\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)forward\2|('|"|`)forward\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md index 25c23854429..0852ffc3339 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a5f09a785aed155c0a56.md @@ -7,17 +7,17 @@ dashedName: step-44 # --description-- -Add a new `case` for `midfielder` that checks if `player.position` equals `midfielder` following the same pattern from the previous step. +Add a new `case` for `"midfielder"` that checks if `player.position` equals `"midfielder"` following the same pattern from the previous step. # --hints-- -You should add a new `case` for `midfielder` inside your `switch` statement. +You should add a new `case` for `"midfielder"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*/) ``` -In your `midfielder` `case`, you should call the `setPlayerCards` function. +In your `"midfielder"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `midfielder`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"midfielder"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*midfielder\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)midfielder\2|('|"|`)midfielder\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md index fdeff91bd0a..fe9c9628251 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2a8e14fb388edd3242527.md @@ -7,17 +7,17 @@ dashedName: step-45 # --description-- -Add a new `case` for `defender` that checks if `player.position` equals `defender` following the same pattern as the previous step. +Add a new `case` for `"defender"` that checks if `player.position` equals `"defender"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `defender` inside your `switch` statement. +You should add a new `case` for `"defender"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*/) ``` -In your `defender` `case`, you should call the `setPlayerCards` function. +In your `"defender"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `defender`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"defender"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*p You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*defender\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)defender\2|('|"|`)defender\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md index b9cf447a3fa..13d4b7ca606 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/63f2aa36fcdc63ee4e18fc37.md @@ -7,17 +7,17 @@ dashedName: step-46 # --description-- -Add a new `case` for `goalkeeper` that checks if `player.position` equals `goalkeeper` following the same pattern as the previous step. +Add a new `case` for `"goalkeeper"` that checks if `player.position` equals `"goalkeeper"` following the same pattern as the previous step. # --hints-- -You should add a new `case` for `goalkeeper` inside your `switch` statement. +You should add a new `case` for `"goalkeeper"` inside your `switch` statement. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*/) ``` -In your `goalkeeper` `case`, you should call the `setPlayerCards` function. +In your `"goalkeeper"` `case`, you should call the `setPlayerCards` function. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(/) @@ -41,7 +41,7 @@ Your `filter()` callback should take a `player` parameter. assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>/) ``` -Your `filter()` callback should implicitly return the result of checking if `player.position` is `goalkeeper`. +Your `filter()` callback should implicitly return the result of checking if `player.position` is `"goalkeeper"`. ```js assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)/) @@ -50,7 +50,7 @@ assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*goalkeeper\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(?:\(\s*player\s*\)|player)\s*=>\s*(?:player\.position\s*===?\s*('|"|`)goalkeeper\2|('|"|`)goalkeeper\3\s*===?\s*player\.position)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md index ef702afe04c..c7f11f6c36e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-modern-javascript-methods-by-building-football-team-cards/641fcfd468185384ac218b7d.md @@ -16,7 +16,7 @@ Below your `setPlayerCards` call, add a `break` statement. You will need to add a `break` statement below your `setPlayerCards` call. ```js -assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\);?\s*break/) +assert.match(code, /\s*case\s*('|"|`)\s*nickname\s*\1\s*:\s*setPlayerCards\(\s*players\.filter\(\s*(\(\s*player\s*\)|player)\s*=>\s*(player\.nickname\s*!==?\s*null|null\s*!==?\s*player\.nickname)\s*\)\s*\)\s*;?\s*break/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md index 305c1ec14aa..aaa78e564fa 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64005ab13a78eb062547c12d.md @@ -14,7 +14,7 @@ Next, within the body of the `if` statement, call the `checkUserInput()` functio You should call the `checkUserInput()` function within the body of your `if` statement. ```js -assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\);?\s*\}/); +assert.match(code, /if\s*\(\s*e\s*\.\s*key\s*===?\s*('|"|`)Enter\1\s*\)\s*\{\s*checkUserInput\(\s*\)\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md index 93c9a2c94ec..b3155ca5863 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644760f4fb15ce765baebb62.md @@ -16,7 +16,7 @@ Add the `return` keyword after `alert()`. You should use the `return` keyword after `alert()`. ```js -assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\);?\s*return;?\s*\}/i); +assert.match(String(checkUserInput), /if\s*\(\s*.+\s*\)\s*\{\s*(window\s*.)?\s*alert\(\s*('|"|`)please provide a decimal number\2\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md index 9fa5bde3e72..df4af71d435 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448b2c9aec64c0ecd41573d.md @@ -14,13 +14,13 @@ Within your `checkUserInput` function, remove the `console.log()` statement. The You should remove the `console.log()` statement from your `checkUserInput` function. ```js -assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*console\.log\((\s|.)*\)/); +assert.notMatch(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*console\.log\((\s|.)*\)/); ``` You should call the `decimalToBinary` function after the `if` statement within the body of your `checkUserInput` function. ```js -assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\);?\s*return\;?\s*\}\s*decimalToBinary\(/); +assert.match(String(checkUserInput), /alert\(\s*('|"|`)\s*(\s|.)*\s*\1\s*\)\s*;?\s*return\s*;?\s*\}\s*decimalToBinary\(/); ``` You should use `parseInt()` to convert the `value` of `numberInput` into a number, and pass that as an argument to the `decimalToBinary` function. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md index 8e9a399f964..4fd6765c342 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6448fefcd6445d6b3d9d63db.md @@ -22,7 +22,7 @@ assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>/); You should log `e` to the console in the body of your callback function. ```js -assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\);?\s*}\s*\)/); +assert.match(code, /('|"|`)keydown\1\s*,\s*(\(\s*e\s*\)|e)\s*=>\s*{\s*console\.log\(\s*e\s*\)\s*;?\s*}\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md index 0bcb2033632..73a77bcc460 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b765b3bf09e6dff5e0931.md @@ -16,7 +16,7 @@ Update the last line of your `while` loop and assign `quotient` to `input`. You should assign `quotient` to `input` at the end of your `while` loop. ```js -assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient;?\s*\}/); +assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*input\s*=\s*quotient\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md index 6225dd172b9..f7c6095cc0f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/644b7ac994d7dd73a61b4fa6.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*inputs\.push\(/); You should use the `.push()` method to append `input` to the `inputs` array. ```js -assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\);?/); +assert.match(String(decimalToBinary), /inputs\.push\(\s*input\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md index 92a77d87e11..be89c69dd0d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b5c05986aba539ba6ca03.md @@ -14,7 +14,7 @@ Set `input` equal to the number `0` for now. We'll change this in the next few s You should set `input` equal to the number `0`. ```js -assert.match(String(decimalToBinary), /input\s*=\s*0;?/); +assert.match(String(decimalToBinary), /input\s*=\s*0\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md index eab2735ed56..51a13134d74 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b65b681a62f5fa125ff62.md @@ -20,7 +20,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*quotients\.push\( You should use the `.push()` method to append `quotient` to the `quotients` array. ```js -assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\);?/); +assert.match(String(decimalToBinary), /quotients\.push\(\s*quotient\s*\)\s*;?/); ``` You should use the `.push()` method on the `remainders` array within your `while` loop. @@ -32,7 +32,7 @@ assert.match(code, /while\s*\(\s*input\s*>\s*0\s*\)\s*\{[\s\S]*remainders\.push\ You should use the `.push()` method to append `remainder` to the `remainders` array. ```js -assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\);?/); +assert.match(String(decimalToBinary), /remainders\.push\(\s*remainder\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md index a9e8abe82bd..f69252b46c7 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9d56b48971997a8055dd.md @@ -20,7 +20,7 @@ assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*re After setting the `innerText` of the `result` element, you should use an early `return` statement to break out of the function early. ```js -assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return;?\s*\}/); +assert.match(String(decimalToBinary), /if\s*\(\s*input\s*===?\s*0\s*\)\s*\{\s*result\.innerText\s*=\s*('|"|`)\s*0\s*\1\s*;?\s*return\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md index 9df37862e14..751b97efed5 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9de38df75b9a5cfc2e85.md @@ -24,7 +24,7 @@ assert.match(code, /let\s+binary\s*/); You should create a variable named `binary` inside your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*/); ``` You should assign `binary` an empty string. @@ -36,7 +36,7 @@ assert.match(code, /let\s+binary\s*=\s*('|"|`)\1\s*;?/); You should remove everything else from the body of your `decimalToBinary` function. ```js -assert.match(code, /const\s+decimalToBinary\s*=\s*\(?\s*input\s*\)?\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); +assert.match(code, /const\s+decimalToBinary\s*=\s*(?:\(\s*input\s*\)|input)\s*=>\s*\{\s*let\s+binary\s*=\s*('|"|`)\1\s*;?\s*\}/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md index f855e33e79e..32cc7bfa5ea 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645b9ea45d3a9a9d711df81a.md @@ -16,7 +16,7 @@ Set the `value` property of `numberInput` to an empty string. You should set the `value` property of `numberInput` to an empty string. ```js -assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\);?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\);?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); +assert.match(String(checkUserInput), /decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\.\s*value\s*=\s*('|"|`)\2|decimalToBinary\((\s|.)*\)\s*;?\s*numberInput\s*\[\s*('|"|`)value\4\s*\]\s*=\s*('|"|`)\5/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md index d0878f9715d..36b8d6c3256 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb07132281a380223e458.md @@ -14,7 +14,7 @@ Then, log `number` to the console after your recursive `countDownAndUp(number - You should log `number` to the console after your recursive `countDownAndUp(number - 1)` function call. ```js -assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\);?\s*console\.log\(\s*number\s*\)/); +assert.match(String(countDownAndUp), /countDownAndUp\(\s*number\s*-\s*1\s*\)\s*;?\s*console\.log\(\s*number\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md index 456d854f789..305dad34633 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/645cb1306eb27a397be7f18c.md @@ -14,7 +14,7 @@ In your base case, log `Reached base case` to the console. You should log `Reached base case` to the console in your base case. ```js -assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\);?\s*return\s*;?\s*\}/i); +assert.match(String(countDownAndUp), /if\s*\(\s*number\s*===?\s*0\s*\)\s*\{\s*console\.log\(\s*('|"|`)\s*Reached base case\s*\1\s*\)\s*;?\s*return\s*;?\s*\}/i); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md index 44e26cb5ab4..ab9d2d88c58 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646bc0e5a60ea131e03f91.md @@ -44,7 +44,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1000` as the second argument to the `setTimeout` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\);?\s*\}?\s*,\s*1000\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Code\s*\1\s*\)\s*;?\s*\}?\s*,\s*1000\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md index 28cff5a2f3f..6cafd655bff 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/64646db2c684b7a3a174a1d0.md @@ -48,7 +48,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\);?\s*\}?\s*,\s*500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*free\s*\1\s*\)\s*;?\s*\}?\s*,\s*500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md index 26eb5f1a966..5b327d4f75d 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/646477c82475ffaf0c3c0771.md @@ -46,7 +46,7 @@ assert.match(code, /setTimeout\(\s*\(\s*\)\s*=>\s*\{?\s*console\.log\(\s*('|"|`) You should pass `1500` as the second argument to the new `setTimeout()` function. ```js -assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\);?\s*\}?\s*,\s*1500\s*\)/); +assert.match(code, /console\.log\(\s*('|"|`)\s*Camp\s*\1\s*\)\s*;?\s*\}?\s*,\s*1500\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md index e92803d2ea1..49b8282a89f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-recursion-by-building-a-decimal-to-binary-converter/6464905afec9efcf7328ce58.md @@ -20,7 +20,7 @@ assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(/); You should pass in `obj` as a parameter to the `.forEach()` method's callback function. ```js -assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*\(?\s*obj\s*\)?\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); +assert.match(String(showAnimation), /animationData\s*\.\s*forEach\(\s*(\(\s*obj\s*\)|obj)\s*=>\s*\{|animationData\s*\.\s*forEach\(\s*function\s*\(\s*obj\s*\)\s*\{/); ``` Тіло функції зворотного виклику методу `.forEach()` має бути порожнім. diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md index b5cd2ff7ff3..f94a98b5c6e 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdebe67ec0f25a4798356.md @@ -34,7 +34,7 @@ assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\ Інструкція `if` має завершити виконання функції. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\);?\s*return\s*;?\s*\}\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*(?:messageInput\.value\s*===?\s*('|"|`)\2|('|"|`)\3\s*===?\s*messageInput\.value)\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\4\s*\)\s*;?\s*return\s*;?\s*\}\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md index 1bb79ed3dd6..1507f346024 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdefa704f232675ed98aa.md @@ -20,19 +20,19 @@ assert.match(code, /const\s+isSpam\s*=/); Використайте стрілковий синтаксис, щоб призначити `isSpam` до функції. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Функція `isSpam` повинна мати єдиний параметр `msg`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)/); ``` Функція `isSpam` повинна неявно повернути `false`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*false;?/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*false\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md index 71d086afa64..08539cb314f 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/641cdf57c3f7ee276e1d9b32.md @@ -7,7 +7,13 @@ dashedName: step-5 # --description-- -Back in your event listener, you need to update the text of the `result` element. +Back in your event listener, you need to update the text of the `result` element. You can use a `ternary` operator to achieve this task. + +Here is an example of assigning the result of a ternary operator to an element's text content: + +```js +el.textContent = condition ? "Use this text if the condition is true" : "Use this text if the condition is false"; +``` After the `if` statement, use a ternary operator to check the truthiness of calling `isSpam()` with `messageInput.value` as the argument. If true, set the `textContent` property on the `result` element to `Oh no! This looks like a spam message.`. Otherwise, set it to `This message does not seem to contain any spam.` @@ -18,37 +24,37 @@ Then set the `messageInput` element's `value` property to an empty string. You should use the assignment operator to set the `textContent` property of the `result` element. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*/) ``` You should call the `isSpam()` function after the assignment operator `=` and before the `?` ternary operator. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(.*\)\s*\?/) ``` You should use ternary syntax to check the truthiness of `isSpam(messageInput.value)`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?/) ``` The truthy expression of your ternary should set the `textContent` property of the `result` element to `Oh no! This looks like a spam message.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:/); ``` The falsy expression of your ternary should set the `textContent` property of the `result` element to `This message does not seem to contain any spam.`. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5;?\s*/); +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*/); ``` After your ternary, set the `value` property on the `messageInput` element to an empty string. ```js -assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\);?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6;?\s*\}/) +assert.match(code, /checkMessageButton\.addEventListener\(\s*('|"|`)click\1\s*,\s*\(\s*\)\s*=>\s*\{\s*if\s*\(\s*messageInput\.value\s*===\s*('|"|`)\2\s*\)\s*\{\s*alert\(\s*('|"|`)Please enter a message\.\3\s*\)\s*;?\s*return\s*;?\s*\}\s*result\.textContent\s*\=\s*isSpam\(\s*messageInput\.value\s*\)\s*\?\s*('|"|`)Oh no! This looks like a spam message.\4\s*:\s*('|"|`)This message does not seem to contain any spam.\5\s*;?\s*messageInput\.value\s*=\s*('|"|`)\6\s*;?\s*\}/) ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md index 45d9f2cfce3..522ec54bb6c 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-regular-expressions-by-building-a-spam-filter/6421f98f4999d1179ce37cb4.md @@ -16,25 +16,25 @@ Use `regex` as the parameter for the callback function, for clarity. Your `isSpam` function should implicitly return the result of `denyList.some()`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*/) +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*/) ``` Your `.some()` method should use arrow syntax for the callback. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?.*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\([^)]*\)|[^\s()]+)\s*=>/); ``` Your `.some()` callback should take `regex` as the parameter. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>/); ``` Your `.some()` callback should implicitly return the result of testing `msg` on `regex`. ```js -assert.match(code, /const\s+isSpam\s*=\s*\(?\s*msg\s*\)?\s*=>\s*denyList\.some\(\s*\(?\s*regex\s*\)?\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); +assert.match(code, /const\s+isSpam\s*=\s*(\(\s*msg\s*\)|msg)\s*=>\s*denyList\.some\(\s*(\(\s*regex\s*\)|regex)\s*=>\s*regex\.test\(\s*msg\s*\)\s*\)/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md index b5f27b4c91e..6ebdb750489 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388ac7154e44b72c74d616.md @@ -22,7 +22,7 @@ assert(code.match(/currentDateParagraph\.textContent\s*=\s*formattedDate/g)); Вам не потрібен рядок `console.log(formattedDate);` у коді. ```js -assert.notMatch(code, /console\.log\(\s*formattedDate\s*\);/); +assert.notMatch(code, /console\.log\(\s*formattedDate\s*\)\s*;?/); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md index db7c4337779..9d167126b06 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388bbcbf6928b83fc424d1.md @@ -15,7 +15,7 @@ element.addEventListener("change", () => { }); ``` -Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `change` and the second argument should be an empty arrow function. +Attach the `addEventListener` method to the `dateOptionsSelectElement`. The first argument of the event listener should be the string `"change"` and the second argument should be an empty arrow function. # --hints-- @@ -25,7 +25,7 @@ You should attach the `addEventListener` method to the `dateOptionsSelectElement assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(/g)); ``` -Your event listener should listen for a `change` event. +Your event listener should listen for a `"change"` event. ```js assert(code.match(/dateOptionsSelectElement\.addEventListener\s*\(\s*('|")change\1/g)); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md index 383de792bd2..71185c062b8 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65388edfdf364fbb04e426f2.md @@ -9,7 +9,7 @@ dashedName: step-17 Якщо користувач вибирає `Year, Month, Day` зі спадного списку, то формат дати має відповідати цьому вибору. -Для цього ви можете додати умову `case` до інструкції `switch`, яка перевіряє відповідність виразу `expr` (після чого йде код до виконання, якщо буде збіг). Ось приклад, де умова `case` перевіряє, чи `expr` дорівнює рядку `case123`: +Для цього ви можете додати умову `case` до інструкції `switch`, яка перевіряє відповідність виразу `expr` (після чого йде код до виконання, якщо буде збіг). Here's an example where the `case` clause checks that `expr` is equal to the string `"case123"`: ```js switch (expr) { @@ -18,12 +18,12 @@ switch (expr) { } ``` -Додайте `case`, де значенням є `yyyy-mm-dd`. Встановіть текстовий вміст змінної `currentDateParagraph` на `formattedDate` в межах `case`. +Add a `case` where the value is `"yyyy-mm-dd"`. Встановіть текстовий вміст змінної `currentDateParagraph` на `formattedDate` в межах `case`. # --hints-- -Додайте `case`, де умовою є `yyyy-mm-dd`. Потім встановіть властивість `textContent` змінної `currentDateParagraph` на `formattedDate`. +You should add a `case` where the condition is `"yyyy-mm-dd"`. Потім встановіть властивість `textContent` змінної `currentDateParagraph` на `formattedDate`. ```js assert(code.match(/case\s*('|")yyyy-mm-dd\1\s*:\s*currentDateParagraph\.textContent\s*=\s*formattedDate/g)); diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md index 4e92552f02e..3725fa384d4 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/653898fa7eee37c57b960e35.md @@ -26,7 +26,7 @@ switch (someVariable) { Додайте інструкцію `break` в межах `case` після логіки. ```js -assert(code.match(/\.join\(\s*('|")-\1\s*\)\;?\n+\s*break/g)); +assert(code.match(/\.join\(\s*('|")-\1\s*\)\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md index 0399e1c0d01..2569289be21 100644 --- a/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md +++ b/curriculum/challenges/ukrainian/15-javascript-algorithms-and-data-structures-22/learn-the-date-object-by-building-a-date-formatter/65389a63d3b1d6c764c0e10e.md @@ -7,13 +7,13 @@ dashedName: step-22 # --description-- -Додайте ще один блок `case` зі значенням `mm-dd-yyyy-h-mm`. У цьому `case` встановіть текстовий вміст `currentDateParagraph` на порожній шаблонний літерал. +Add another `case` with the value `"mm-dd-yyyy-h-mm"`. У цьому `case` встановіть текстовий вміст `currentDateParagraph` на порожній шаблонний літерал. Крім того, обов’язково використайте інструкцію `break`, щоб завершити інструкцію `switch`. # --hints-- -Додайте `case`, де умовою є `mm-dd-yyyy-h-mm`, а потім встановіть властивість `textContent` змінної `currentDateParagraph` на порожні шаблонні літерали. +You should add a `case` where the condition is `"mm-dd-yyyy-h-mm"`, then set the `textContent` property of `currentDateParagraph` equal to empty template literals. ```js assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.textContent\s*=\s*``/g)); @@ -22,7 +22,7 @@ assert(code.match(/case\s*('|")mm-dd-yyyy-h-mm\1\s*:\s*currentDateParagraph\.tex Додайте інструкцію `break` в межах `case` після логіки. ```js -assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\;?\n+\s*break/g)); +assert(code.match(/currentDateParagraph\.textContent\s*=\s*``\s*;?\n+\s*break/g)); ``` # --seed-- diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md index da607b2c513..4dbd8d70c30 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-build-a-recipe-project/top-build-a-recipe-project.md @@ -171,7 +171,7 @@ assert(allAnchorsHaveHrefHash && anchorTags.length > 0);

                                                Creamy Chocolate Fudge

                                                - A delicious chocolate fudge dessert + A delicious chocolate fudge dessert

                                                Description

                                                This recipe is for a rich and creamy chocolate fudge that is sure to satisfy your sweet tooth. It's perfect for a special occasion or as a tasty treat for any time of the year.

                                                This recipe is easy to follow and only requires a few simple ingredients. With just a few steps, you'll be able to create a delicious dessert that everyone will love.

                                                diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md index 37a949e37f7..800c51cda4e 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-b.md @@ -11,7 +11,7 @@ dashedName: introduction-flexbox-question-b Гнучкий контейнер — це будь-який елемент, який має `display: flex`. Гнучкий предмет — це будь-який елемент, який живе в гнучкому контейнері. - +An outer rectangle representing a flex container encompassing three smaller inner rectangles lined up side by side, each representing a flex item. # --question-- diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md index cdf20f24fbb..b0e1e018534 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-c.md @@ -9,12 +9,13 @@ dashedName: introduction-flexbox-question-c Як не дивно, будь-який елемент може бути і гнучким контейнером, і гнучким предметом. Іншими словами, ви можете додати `display: flex` до гнучкого предмета, а потім використати flexbox, щоб розташувати його дочірні елементи. - +a flex container that has multiple flex items, within those flex items are nested flex items as well. Making the parent of those nested flex items also a flex container. Створення та вкладання декількох гнучких контейнерів та предметів — це основний спосіб, яким ви будете створювати складні макети. Зображення нижче було створено виключно за допомогою flexbox, щоб розмістити, змінити розмір та розташувати різні елементи. Flexbox — це дуже потужний інструмент. - +a complex layout of flex items and flex containers. There are multiple flex containers nested into each other, thus making them flex items as well +Certainly, the image features a representation of a CSS Flexbox layout with nested flex containers. The outer container is denoted as "ALSO a flex container" highlighted in blue, and within it is another container marked as "with flex items" in red. Inside the red container, there are three items labeled as "flex items" in peach. This demonstrates that a flex container can be nested within another flex container and contain its own flex items, showcasing the recursive nature of Flexbox layout structures. # --question-- diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md index ddb34715f56..644ce83505f 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-e.md @@ -13,7 +13,7 @@ dashedName: introduction-flexbox-question-e У цьому випадку `flex` є скороченням властивостей `flex-grow`, `flex-shrink` та `flex-basis`. -скорочення flex +CSS code setting the flex property to 1 for a div element. `flex: 1` зі знімка екрана вище дорівнює `flex-grow: 1`, `flex-shrink: 1`, `flex-basis: 0`. diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md index 4630f79c913..3ec804e767c 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-j.md @@ -17,7 +17,7 @@ dashedName: introduction-flexbox-question-j Видаліть `flex: 1` з `.item` та додайте `justify-content: space-between` до `.container`. Результат повинен мати схожий вигляд: -зображення з трьома блакитними квадратами, розкиданими по всій ширині контейнера +Three small boxes within a much larger rectangle. The boxes are arranged in a single row, one close to the left edge of the container, one close to the right edge of the container, and the last directly in the middle of the container, placing as much space as possible between each box. `justify-content` вирівнює предмети по **головній осі**. До цієї властивості можна використати декілька значень. Про решту ви дізнаєтесь в завданнях з читання. А зараз спробуйте використати значення `center`, що відцентрує блоки вздовж головної осі. diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md index c8630d98e07..fec0d981296 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-introduction-to-flexbox/introduction-flexbox-question-k.md @@ -13,7 +13,7 @@ allowtransparency="true" class="cp_embed_iframe " frameborder="0" height="400" w Щоб змінити розташування предметів по перехресній осі, використайте `align-items`. Спробуйте розмістити блоки по центру контейнера, додавши `align-items: center` до `.container`. Бажаний результат виглядає так: -зображення з трьома блакитними квадратами, розташованими за центром гнучкого контейнера +three blue squares centered in the middle of the flex container Оскільки `justify-content` та `align-items` базуються на головній та перехресній осях контейнера, то їхня поведінка змінюється, якщо ви змінюєте `flex-direction` гнучкого контейнера. Наприклад, якщо змінити `flex-direction` на `column`, то `justify-content` вирівнюватиме вертикально, а `align-items` — горизонтально. Однак найпоширенішою поведінкою є поведінка за замовчуванням: `justify-content` вирівнює предмети горизонтально (оскільки головна вісь за замовчуванням горизонтальна), а `align-items` вирівнює їх вертикально. Одна з найбільших труднощів, з якими початківці стикаються при роботі з flexbox, — це плутанина при зміні поведінки. diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md index 2e3cb588edf..2bf958706d3 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-html-foundations/html-foundations-question-a.md @@ -16,7 +16,7 @@ dashedName: html-foundations-question-a Повний елемент абзацу виглядає так: -діаграма елемента +An opening p tag, followed by the content string "some text content", followed by a closing p tag. # --assignment-- diff --git a/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md b/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md index a7a911eb7f6..e1437e172ca 100644 --- a/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md +++ b/curriculum/challenges/ukrainian/16-the-odin-project/top-learn-variables-and-operators/learn-variables-and-operators-question-a.md @@ -4,6 +4,7 @@ title: Learn Variables and Operators Question A challengeType: 15 dashedName: learn-variables-and-operators-question-a --- + # --description-- The simplest way to get started is to create an HTML file with the JavaScript code inside of it. Type the basic HTML skeleton into a file on your computer somewhere: @@ -51,7 +52,7 @@ JavaScript code must be written in the `` section of an HTML document for --- -JavaScript can be included directly in an HTML file using a `